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)
Buscar
Categorías
Read More
Научная фантастика и фэнтези
Тёмный рыцарь: Возрождение легенды. The Dark Knight Rises. (2012)
Восемь лет назад Бэтмен растворился в ночи, превратившись из героя в беглеца. Приняв на себя вину...
By Nikolai Pokryshkin 2022-12-25 10:15:19 0 25K
Business
The Challenge of Educating Other Functions About Product Marketing
Product Marketing Managers (PMMs) are often masters of external communication—crafting...
By Dacey Rankins 2025-09-15 18:59:22 0 1K
Mental Health
Psychosis: Etymology
EtymologyThe word psychosis was introduced to the psychiatric literature in 1841 by Karl...
By Kelsey Rodriguez 2023-05-18 17:18:20 0 10K
Social Issues
I Care About You (2021)
A crooked legal guardian who drains the savings of her elderly wards meets her match when a woman...
By Leonard Pokrovski 2022-09-16 18:22:39 0 26K
Ужасы
Сияние. The Shining. (1980)
Джек Торренс с женой и сыном приезжает в элегантный отдалённый отель, чтобы работать смотрителем...
By Nikolai Pokryshkin 2022-12-17 18:50:47 0 25K

BigMoney.VIP Powered by Hosting Pokrov