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)
Поиск
Категории
Больше
Business
Overall Satisfaction: Why It Matters and How to Measure It
Understanding how satisfied customers are with your product or service is one of the most...
От Dacey Rankins 2025-07-24 18:16:05 0 7Кб
Economics
How Does Commercial Policy Affect the Economy?
How Does Commercial Policy Affect the Economy? Commercial policy is one of the most powerful...
От Leonard Pokrovski 2026-02-23 14:54:09 0 7Кб
Business
What Is Fair Use?
A creator spends months writing a book. A filmmaker spends years producing a documentary. A...
От Dacey Rankins 2026-06-12 16:33:51 0 288
Personal Finance
How Much Can I Borrow?
How Much Can I Borrow? What Amount Will Lenders Approve, What Is the Maximum Mortgage I Can Get,...
От Leonard Pokrovski 2025-11-14 21:43:14 0 12Кб
Life Issues
Mary and Max. (2009)
A tale of friendship between two unlikely pen pals: Mary, a lonely, eight-year-old girl living in...
От Leonard Pokrovski 2023-04-07 20:47:17 0 31Кб

BigMoney.VIP Powered by Hosting Pokrov