Encoding and Decoding Base64 Strings in Python

0
13K

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)
Search
Categories
Read More
Personal Finance
What Happens If I Delay Social Security?
What Happens If I Delay Social Security? Understanding Delayed Retirement Credits and How Much...
By Leonard Pokrovski 2025-12-12 22:27:00 0 599
Business
What’s Not Working?
One of the most powerful yet uncomfortable questions in personal growth, career development, or...
By Dacey Rankins 2025-09-09 14:24:43 0 3K
Home Automation
Home Automation
Home automation or domotics is building automation for a home, called a smart home or smart...
By FWhoop Xelqua 2022-09-07 13:28:52 0 45K
Personal Finance
What Interest Rate Will I Pay? Understanding APR, Fees, and Loan Terms
What Interest Rate Will I Pay? Understanding APR, Fees, and Loan Terms When you take out a loan,...
By Leonard Pokrovski 2025-11-06 19:13:48 0 2K
Mental Health
Dyslexia: Dual route theory
The dual-route theory of reading aloud was first described in the early 1970s. This theory...
By Kelsey Rodriguez 2023-06-27 18:45:02 0 11K

BigMoney.VIP Powered by Hosting Pokrov