Encoding and Decoding Base64 Strings in Python

0
6K

The Base64 encoding is used to convert bytes that have binary or text data into ASCII characters. Encoding prevents the data from getting corrupted when it is transferred or processed through a text-only system. In this article, we will discuss about Base64 encoding and decoding and its uses to encode and decode binary and text data. Each Base64 character represents 6 bits of data. it is also important to note that it is not meant for encryption for obvious reasons.

 

import base64
  
sample_string = "Hello world!"
sample_string_bytes = sample_string.encode("ascii")
  
base64_bytes = base64.b64encode(sample_string_bytes)
base64_string = base64_bytes.decode("ascii")
  
print(base64_string)
Căutare
Categorii
Citeste mai mult
Business
Starting and Growing an Online Business: A Complete Guide
In today’s digital age, starting an online business is more accessible than ever. Whether...
By Dacey Rankins 2024-12-16 14:26:41 0 399
Energy
Energy in Business
Business is ruled by energy. I'm not talking about spirituality or self-awareness, I'm talking...
By FWhoop Xelqua 2023-07-29 20:44:36 0 519K
Social Issues
Witness for the Prosecution. (1957)
A veteran British barrister must defend his client in a murder trial that has surprise after...
By Leonard Pokrovski 2022-12-20 17:51:43 0 11K
Financial Services
The Phillips curve in the Keynesian perspective
Key points A Phillips curve shows the tradeoff between unemployment and inflation...
By Mark Lorenzo 2023-06-21 18:14:23 0 5K
Entertaining
30 home entertainment for the whole family to help pass the time
Games, tricks and experiments that children (and adults) will appreciate.   Because of the...
By FWhoop Xelqua 2022-11-25 17:33:22 0 23K
image/svg+xml


BigMoney.VIP Powered by Hosting Pokrov