Python: Convert string to and from base64 format
Base64 encoding is a format that can be used for data transfer in HTML or general data representation as you don't need to escape it. To convert a stream of byte object to base64 and vice versa, use the following example.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import base64 | |
data = base64.b64encode(b'Hello World') | |
print(base64.b64decode(data)) | |
# Hello World |
No comments:
Post a Comment