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)
Căutare
Categorii
Citeste mai mult
Graphic Design
The Art and Impact of Graphic Design: Shaping Visual Communication
Graphic design is a powerful tool that shapes how we perceive and interact with the world...
By Dacey Rankins 2024-12-03 15:37:48 0 11K
Mental Health
ADHD: Diagnosis Classification
As with many other psychiatric disorders, a formal diagnosis should be made by a qualified...
By Kelsey Rodriguez 2023-04-20 19:05:08 0 11K
Business
What is a Startup Founder?
A startup founder is an entrepreneur who creates and establishes a new business venture,...
By Dacey Rankins 2025-03-31 16:21:37 0 7K
Travel
Named the most visited attractions in the world
The authoritative publication Travel + Leisure has published a list of the main tourist...
By FWhoop Xelqua 2023-01-03 14:47:15 0 23K
Finance
The Main Types and Segments of Fintech
The Main Types and Segments of Fintech Introduction Financial technology—better known as...
By Leonard Pokrovski 2025-10-09 17:29:32 0 2K

BigMoney.VIP Powered by Hosting Pokrov