Encoding and Decoding Base64 Strings in Python

0
14K

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
Social Issues
Goodfellas. (1990)
The story of Henry Hill and his life in the mob, covering his relationship with his wife Karen...
Por Leonard Pokrovski 2022-11-14 19:06:17 0 31K
Marketing and Advertising
How Does Google AdSense Work?
Google AdSense is one of the most widely used monetization platforms on the internet, yet many...
Por Dacey Rankins 2025-12-24 20:24:57 0 3K
Социальные проблемы
Последний Парадизо. The Last Paradiso. (2021)
Италия, 1950-е.Свободолюбивый фермер борется за лучшие условия труда.Он мечтает о любви,...
Por Nikolai Pokryshkin 2022-09-16 18:07:46 0 27K
Business
Product Development Stages: How to Create Your Product and Sell It Successfully
Product Development Stages: How to Create Your Product and Sell It Successfully  ...
Por Leonard Pokrovski 2024-07-27 11:18:40 0 22K
Ужасы
Время. Old. (2021)
Отправившись в отпуск на тропический остров, семья с двумя детьми решает последовать совету...
Por Nikolai Pokryshkin 2022-09-11 22:13:06 0 42K

BigMoney.VIP Powered by Hosting Pokrov