Encoding and Decoding Base64 Strings in Python

0
10Кб

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)
Поиск
Категории
Больше
Business
What Are Investors' Key Considerations in Late-Stage Startups?
Investing in late-stage startups requires a thorough evaluation of multiple factors to assess...
От Dacey Rankins 2025-03-06 20:39:08 0 5Кб
Карты
Geography ; World Maps
A geographic chart is a scaled-down, generalized image of the surface of the Earth, another...
От FWhoop Xelqua 2023-02-23 16:21:56 0 16Кб
Nature and Science
My Neighbor Totoro. (1988)
When two girls move to the country to be near their ailing mother, they have adventures with the...
От Leonard Pokrovski 2023-03-15 17:30:45 0 23Кб
Business
Top 30 Customer Feedback Questions For Product Surveys
In today’s highly competitive market, understanding your customers' experiences with your...
От Dacey Rankins 2025-05-30 14:50:22 0 4Кб
Социальные проблемы
Крестный отец. The Godfather. (1972)
Криминальная сага, повествующая о нью-йоркской сицилийской мафиозной семье Корлеоне. Фильм...
От Nikolai Pokryshkin 2022-10-25 11:42:13 0 30Кб
image/svg+xml


BigMoney.VIP Powered by Hosting Pokrov