Encoding and Decoding Base64 Strings in Python

0
13K

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)
Pesquisar
Categorias
Leia Mais
Спорт
Бойцовский клуб. Fight Club. (1999)
Сотрудник страховой компании страдает хронической бессонницей и отчаянно пытается вырваться из...
Por Nikolai Pokryshkin 2022-11-07 20:17:51 0 44K
Жизненные вопросы
Клаус. Klaus. (2019)
Владелец почтовой империи, чтобы научить ленивого отпрыска по имени Джеспер уму-разуму,...
Por Nikolai Pokryshkin 2023-03-18 11:47:08 0 33K
Social Issues
A Clockwork Orange. (1971)
In the future, a sadistic gang leader is imprisoned and volunteers for a conduct-aversion...
Por Leonard Pokrovski 2023-01-20 18:37:17 0 28K
Business
The Falcon Heavy
The Falcon Heavy is an American super-heavy launch vehicle (LV) with the ability to reuse the...
Por Leonard Pokrovski 2024-07-27 12:01:38 0 22K
Financial Services
10 questions to ask mortgage lenders
1) How much can I borrow to buy a home? When determining how much you can borrow, lenders...
Por Mark Lorenzo 2023-05-30 18:41:24 0 21K

BigMoney.VIP Powered by Hosting Pokrov