Encoding and Decoding Base64 Strings in Python

0
14K

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)
Site içinde arama yapın
Kategoriler
Read More
Другое
Рождество на двоих. Last Christmas. (2019)
Кейт работает в магазине рождественских товаров, злоупотребляет выпивкой и давно бросила...
By Nikolai Pokryshkin 2022-09-11 23:04:49 0 30K
Business
What Brings Me Peace or Fulfillment Right Now?
Life often moves so quickly that we rarely pause to ask ourselves: What brings me peace or...
By Dacey Rankins 2025-09-09 14:25:53 0 4K
Business
What Financial Considerations Must We Clarify in a Partnership?
Entering a business partnership is one of the most significant decisions any entrepreneur can...
By Dacey Rankins 2025-12-01 15:03:09 0 3K
Sport
The King of Kong: A Fistful of Quarters (2007)
Die-hard gamers compete to break world records on classic arcade games. My Link
By Leonard Pokrovski 2023-07-25 19:20:21 0 26K
Television
FOX 43 Live TV, York, Pennsylvania, USA.
FOX43+ features the latest breaking news and weather, plus daily talk shows, coverage of your...
By Nikolai Pokrovski 2022-11-25 15:11:43 0 40K

BigMoney.VIP Powered by Hosting Pokrov