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)
Search
Categories
Read More
Cultures and Groups
Art in Culture: A Timeless Reflection of Society
Art has long been an essential element of human civilization, playing a profound role in shaping...
By Dacey Rankins 2025-01-22 14:28:16 0 5K
Business
Do I Need a Business Plan?
When starting a business, one of the first questions you may ask is whether you need a business...
By Dacey Rankins 2025-02-06 15:16:25 0 10K
Business
Examples of guerrilla marketing – promotion through creativity in advertising with a small budget
Many have heard of the term guerrilla marketing, but few have really resorted to it, and it is an...
By Dacey Rankins 2024-09-04 15:56:15 0 9K
Programming
Python List Slicing
In Python, list slicing is a common practice and it is the most used technique for programmers to...
By Jesse Thomas 2023-03-08 16:49:21 0 7K
Reference
The Significance of References: Building Trust and Credibility
In the vast landscape of academia, employment, and various professional endeavors, references...
By Dacey Rankins 2024-05-16 19:23:54 0 13K
image/svg+xml


BigMoney.VIP Powered by Hosting Pokrov