Encoding and Decoding Base64 Strings in Python

0
10K

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
Business
10 Questions to Ask About Company Culture in an Interview
When interviewing for a new job, many candidates focus on responsibilities, salary, and...
By Dacey Rankins 2025-06-12 15:20:39 0 3K
Programming
Python __init__ Method
The __init__ method is the Python equivalent of the C++ constructor in an...
By Jesse Thomas 2023-03-17 20:19:20 0 8K
Television
CBS. WREG Channel 3, Live TV. Memphis, Tennessee, United States.
WREG-TV (UHF digital channel 28), is a CBS-affiliated television station located in Memphis,...
By Nikolai Pokryshkin 2022-11-06 12:08:21 0 35K
Business
What Strategies Can Help Increase My Follower Count?
Growing your follower count is essential for establishing a strong presence on social media and...
By Dacey Rankins 2025-02-18 15:33:43 0 6K
Business
Anti-crisis manager: what is it's role in a crisis?
Anti-crisis manager: what is it's role in a crisis?   "I noticed the moment when...
By Leonard Pokrovski 2024-07-18 20:05:58 0 25K
image/svg+xml


BigMoney.VIP Powered by Hosting Pokrov