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
Mental Health
ADHD: Comorbidities / Trauma
ADHD, trauma, and Adverse Childhood Experiences are also comorbid, which could in part be...
By Kelsey Rodriguez 2023-03-28 15:05:58 0 12K
Money
How does a credit card work?
How does a credit card work? Credit cards are one of the most widely used financial tools in the...
By Leonard Pokrovski 2025-09-17 19:47:16 0 5K
Business
How do I attract investors for my business?
Securing investors is a crucial step for many entrepreneurs looking to grow their businesses....
By Dacey Rankins 2025-03-13 16:39:00 0 14K
Aging
Can Man Challenge His Genes?
Theoretically, living organisms can live for a very long time, almost forever. Where did such an...
By Dacey Rankins 2024-04-10 13:09:34 0 15K
Social Issues
Crisis. (2021)
Set against the backdrop of the opioid epidemic, stories of an undercover cop, a professor, and a...
By Leonard Pokrovski 2022-09-15 18:57:07 0 30K

BigMoney.VIP Powered by Hosting Pokrov