Encoding and Decoding Base64 Strings in Python

0
8K

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
Trains and Railroads
Unusual railways of the world
Such a familiar thing for us - the railway! One of the most reliable (safe), affordable...
By FWhoop Xelqua 2022-11-18 12:58:56 0 18K
Financial Services
Aggregate demand in Keynesian analysis
Key points Aggregate demand is the sum of four components: consumption,...
By Mark Lorenzo 2023-03-15 17:18:10 0 10K
History
13th (2016)
An in-depth look at the prison system in the United States and how it reveals the nation's...
By Leonard Pokrovski 2023-07-11 20:31:04 0 19K
Social Issues
John Wick: Chapter 4. (2023)
John Wick uncovers a path to defeating The High Table. But before he can earn his freedom, Wick...
By Leonard Pokrovski 2023-03-30 19:36:31 0 20K
Научная фантастика и фэнтези
Как приручить дракона. How to Train Your Dragon. (2010)
Вы узнаете историю подростка Иккинга, которому не слишком близки традиции его героического...
By Nikolai Pokryshkin 2023-04-07 13:57:17 0 23K
image/svg+xml


BigMoney.VIP Powered by Hosting Pokrov