String To Base64
What is Base64 Encoding?
Base64 is a group of binary-to-text encoding schemes that represent binary data in an ASCII string format by translating it into a radix-64 representation. The term Base64 originates from a specific MIME content transfer encoding.
How to convert String to Base64?
To convert String to Base64, we need to encode the String. There are many ways to encode a String to Base64. One way is to use the base64 module in Python.
Example
Let's convert the String "Hello" to Base64.
import base64 string = "Hello" base64_string = base64.b64encode(string.encode("utf-8")) print(base64_string) # b'SGVsbG8='
Become a Sponsor![Heart with ribbon](/_next/image?url=%2Fheart-with-ribbon.png&w=48&q=75)
Become a sponsor and help us maintain and improve this project. Every contribution counts. Thank you!
GitHub Sponsors