Encoding and Decoding Base64 Strings in Python

0
12K

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)
Search
Categories
Read More
Programming
JavaScript forEach()
The forEach() method is an iterative method. It calls a...
By Jesse Thomas 2023-05-15 20:06:26 0 10K
Internet
Google ads - Youtube ads
Part 5: Google Shopping / Google ads (bigmoney.vip) YouTube advertising in numbers YouTube is...
By FWhoop Xelqua 2023-02-09 16:05:55 0 20K
Senses
Feeling (psychology)
Feeling (psychology) Sensibility is a human emotional process that reflects...
By Leonard Pokrovski 2024-04-22 21:19:18 0 16K
Conditions and Diseases
Diseases of civilization, why they are called so, what is their cause, the main directions of prevention
Diseases of civilization, why they are called so, what is their cause, the main directions of...
By Leonard Pokrovski 2024-04-13 11:34:50 0 15K
Business
What Motivates My Team Members? Uncovering the Intrinsic and Extrinsic Drivers of Engagement
One of the most important—and often most elusive—questions leaders ask is:“What...
By Dacey Rankins 2025-07-16 15:48:08 0 3K

BigMoney.VIP Powered by Hosting Pokrov