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
Business
What Motivates and Retains Employees Here?
Understanding what drives and keeps employees engaged in a company gives insight into its...
Por Dacey Rankins 2025-08-09 18:31:13 0 8K
Социальные проблемы
Олдбой. Oldboy. (2003)
1988 год. Обыкновенный и ничем непримечательный бизнесмен О Дэ-cу в день трёхлетия дочери по пути...
Por Nikolai Pokryshkin 2022-12-26 12:04:09 0 27K
Stories
Unforgiven. (1992)
Retired Old West gunslinger William Munny reluctantly takes on one last job, with the help of his...
Por Leonard Pokrovski 2023-02-14 14:32:39 0 20K
Искусство, культура и развлечения
Сансет бульвар. Sunset Blvd. (1950)
Молодой сценарист Джо Гиллис сидит на мели, его преследуют кредиторы, ему не на что поесть, ему...
Por Nikolai Pokryshkin 2022-12-15 20:27:02 0 28K
Жизненные вопросы
Убить пересмешника. To Kill a Mockingbird. (1962)
Юрист из Алабамы в одиночку воспитывает двоих детей. В обстановке экономической депрессии,...
Por Nikolai Pokryshkin 2023-01-23 15:27:26 0 25K

BigMoney.VIP Powered by Hosting Pokrov