Encoding and Decoding Base64 Strings in Python

0
12K

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
Arts, Culture and Entertainment
Annette. (2021)
Los Angeles, nowadays. Henry is a stand-up comedian with a fierce humor. Ann, an internationally...
By Nikolai Pokryshkin 2022-09-01 20:11:00 1 40K
Child Health
Understanding Child Health: Foundations for a Lifetime of Wellness
Child health is one of the most important aspects of overall well-being. Early childhood is a...
By Dacey Rankins 2024-11-28 15:00:23 0 8K
Science Fiction and Fantasy
Logan. (2017)
In a future where mutants are nearly extinct, an elderly and weary Logan leads a quiet life. But...
By Leonard Pokrovski 2023-04-20 20:33:24 0 22K
Научная фантастика и фэнтези
Ая и ведьма. Earwig and the Witch. (2021)
Несмотря на то что 10-летняя Ая не знает родительской ласки и воспитывается в детском приюте...
By Nikolai Pokryshkin 2022-09-21 19:57:32 0 35K
Business
How to Effectively Measure Customer Satisfaction: A Guide to CSAT
Customer satisfaction is one of the key metrics of customer service, and it's an axiom. It allows...
By Dacey Rankins 2024-09-19 16:59:32 0 17K

BigMoney.VIP Powered by Hosting Pokrov