Encoding and Decoding Base64 Strings in Python

0
9K

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
Financial Services
Economic efficiency
Key Points Economic efficiency is the idea that it is impossible to improve...
By Mark Lorenzo 2023-07-11 19:48:45 0 8K
Programming
Create AI with Python
If you’re just starting out in the artificial intelligence (AI) world, then Python is a...
By Jesse Thomas 2023-05-01 19:27:14 0 7K
Mental Health
ADHD: History
Hyperactivity has long been part of the human condition. Sir Alexander Crichton describes "mental...
By Kelsey Rodriguez 2023-05-08 19:41:00 0 8K
Social Issues
The Deer Hunter. (1978)
An in-depth examination of the ways in which the Vietnam War impacts and disrupts the lives of...
By Leonard Pokrovski 2023-03-31 19:52:57 0 25K
Electronics and Electrical
Experiments of Heinrich Hertz: discovery and research of radio waves
At the end of the 19th century, when the science of electricity was still in its infancy, one man...
By Michael Pokrovski 2024-03-12 21:06:56 0 24K
image/svg+xml


BigMoney.VIP Powered by Hosting Pokrov