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)
Buscar
Categorías
Read More
Central America
Top 14 Attractions to Visit in Central America
Central America is a strip of land that connects North America and South America, but for...
By FWhoop Xelqua 2023-04-01 17:58:30 0 31K
Sport
Hoop Dreams (1994)
A film following the lives of two inner-city Chicago boys who struggle to become college...
By Leonard Pokrovski 2023-07-09 20:20:54 0 22K
Contests
International Art Exhibit
All authors working in the formats of contemporary art are invited to participate in the NordArt...
By FWhoop Xelqua 2023-02-26 17:44:53 0 19K
Business
What Type of Business Should I Start?
Starting a business is an exciting venture, but choosing the right type can feel overwhelming....
By Dacey Rankins 2025-02-06 15:01:46 0 10K
Sport
Rocky. (1976)
A small-time Philadelphia boxer gets a supremely rare chance to fight the world heavyweight...
By Leonard Pokrovski 2023-04-16 19:46:10 0 27K

BigMoney.VIP Powered by Hosting Pokrov