Encoding and Decoding Base64 Strings in Python

0
11K

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)
Cerca
Categorie
Leggi tutto
Sport
Ford v Ferrari. (2019)
American car designer Carroll Shelby and driver Ken Miles battle corporate interference and the...
By Leonard Pokrovski 2023-04-14 17:05:21 0 24K
Социальные проблемы
Стойкая броня. Calm with Horses. (2020)
Бывший боксер Дуглас Армстронг, чтобы прокормить семью, устраивается на работу в банду крупных и...
By Nikolai Pokryshkin 2022-10-20 13:23:49 0 27K
Institutions
TOP 15 Research Universities
The world was built as the product of intensive research. Most of the world's stunning...
By FWhoop Xelqua 2022-12-11 15:49:25 0 18K
Life Issues
Memento. (2000)
A man with short-term memory loss attempts to track down his wife's murderer. My Link
By Leonard Pokrovski 2022-12-13 21:06:02 0 23K
Entertainment
Exploring Kids and Teens Entertainment: From Screen Time to Creative Play
Exploring Kids and Teens Entertainment: From Screen Time to Creative Play Entertainment plays a...
By Leonard Pokrovski 2024-04-30 15:11:22 0 31K

BigMoney.VIP Powered by Hosting Pokrov