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
Alternative Medicine
Integrative and Other Medicine: Are We in a Trap?
Integrative and Other Medicine: Are We in a Trap? The situation is somewhat strange, to put it...
By Leonard Pokrovski 2024-04-10 21:46:43 0 17K
Business
How Do Social Media Platforms Generate Leads?
Social media is no longer just a place to post content or build awareness. Today, it is one of...
By Dacey Rankins 2025-12-17 19:06:57 0 497
Architecture
Architecture
Architecture is the art and science of building, designing buildings and structures (including...
By FWhoop Xelqua 2023-06-20 18:14:39 0 27K
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
Business
How an illustrator can promote himself in the international market
How an illustrator can promote himself in the international market We will tell you...
By Leonard Pokrovski 2024-07-30 18:40:02 0 22K

BigMoney.VIP Powered by Hosting Pokrov