Base64 Encoding Decoding in Python Programming


Python Programming Base64 Encoding Decoding Code Example
Python Base64 Decode/Encode

In order to do base64 encoding and decoding in Python Programming, make use of the base64 package,

Code Example:
"""
Base 64 Encoding Decoding in
Python Programming

Author: Code2care.org
Date: 03-Apr-2022
Version: 1.0

"""

import base64

plan_text_string = 'Hello there! Python'

# Base64 Encode Example
base64_encoded_string_result = base64.b64encode(plan_text_string.encode('utf-8'))
print(base64_encoded_string_result)

# Base64 Decode Code
base64_encoded_string = 'SGVsbG8gdGhlcmUhIFB5dGhvbg=='
base64_decoded_string_result = base64.b64decode(base64_encoded_string).decode('utf-8')
print(base64_decoded_string_result)
Output:
b'SGVsbG8gdGhlcmUhIFB5dGhvbg=='
Hello there! Python

Top Hashtags:

Advertisements

Advertisements




Advertisements