Encoding and Decoding Base64 Strings in Python

0
14Кб

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)
Поиск
Категории
Больше
Социальные проблемы
К северу через северо-запад. North by Northwest. (1959)
Однажды успешного рекламного агента Роджера Торнхилла ошибочно принимают за агента разведки...
От Nikolai Pokryshkin 2023-01-16 18:44:14 0 23Кб
Biology
Biology
Biology (Greek: βιολογία; from Ancient Greek:...
От FWhoop Xelqua 2023-03-03 16:42:32 0 22Кб
Business
Crowdfunding for Business: What It Is, How It Works, and What Are the Crowdfunding Platforms for Projects
Crowdfunding for Business: What It Is, How It Works, and What Are the Crowdfunding Platforms for...
От Leonard Pokrovski 2024-08-01 21:59:41 0 19Кб
CAD and CAM
What is CAD and CAM?
What is CAD and CAM?Today, in order to achieve success in the market, an industrial enterprise is...
От Dacey Rankins 2024-03-20 15:18:19 0 27Кб
Искусство, культура и развлечения
Аннетт. Annette. (2021)
Действие развернётся в Лос-Анджелесе. По сюжету Генри работает стендап-комиком, а его супруга Энн...
От Nikolai Pokryshkin 2022-09-03 21:19:35 0 50Кб

BigMoney.VIP Powered by Hosting Pokrov