Encoding and Decoding Base64 Strings in Python
Posted 2023-03-10 20:59:12
0
6K
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
)
Căutare
Categorii
- Arts
- Business
- Computers
- Jocuri
- Health
- Home
- Kids and Teens
- Money
- News
- Recreation
- Reference
- Regional
- Science
- Shopping
- Society
- Sports
- Бизнес
- Деньги
- Дом
- Досуг
- Здоровье
- Игры
- Искусство
- Источники информации
- Компьютеры
- Наука
- Новости и СМИ
- Общество
- Покупки
- Спорт
- Страны и регионы
- World
Citeste mai mult
Starting and Growing an Online Business: A Complete Guide
In today’s digital age, starting an online business is more accessible than ever. Whether...
Energy in Business
Business is ruled by energy. I'm not talking about spirituality or self-awareness, I'm talking...
Witness for the Prosecution. (1957)
A veteran British barrister must defend his client in a murder trial that has surprise after...
The Phillips curve in the Keynesian perspective
Key points
A Phillips curve shows the tradeoff between unemployment and inflation...
30 home entertainment for the whole family to help pass the time
Games, tricks and experiments that children (and adults) will appreciate.
Because of the...