Encoding and Decoding Base64 Strings in Python

0
15Кб

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)
Поиск
Категории
Больше
Социальные проблемы
Доктор Стрейнджлав, или Как я научился не волноваться и полюбил атомную бомбу. Dr. Strangelove or: How I Learned to Stop Worrying and Love the Bomb. (1964)
Одержимый мыслью, что коммунисты намереваются украсть у американцев их «бесценные телесные...
От Nikolai Pokryshkin 2022-12-24 11:18:45 0 32Кб
Business and Corporate Finance
What Does a CFO Do in a Small Business?
What Does a CFO Do in a Small Business? When people hear the title Chief Financial Officer...
От Leonard Pokrovski 2026-01-13 18:31:37 0 5Кб
Economics
How does income inequality affect opportunity?
How Does Income Inequality Affect Opportunity? Income inequality refers to the uneven...
От Leonard Pokrovski 2026-07-08 00:02:03 0 941
Arts and Entertainment
Art and Entertainment Industry
“I'm not here for your amusement. You're here for mine.”Johnny RottenArt analyzes...
От FWhoop Xelqua 2023-07-18 22:26:15 0 30Кб
Productivity
How does caffeine affect focus?
How Does Caffeine Affect Focus? Caffeine is one of the most widely consumed psychoactive...
От Michael Pokrovski 2026-04-18 07:16:01 0 5Кб

BigMoney.VIP Powered by Hosting Pokrov