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)
Поиск
Категории
Больше
Television
Fox 4 Live TV Kansas City, Missouri, USA.
WDAF-TV, virtual channel 4 (UHF digital channel 34), is a FOX-affiliated television station...
От Nikolai Pokryshkin 2022-10-20 09:53:37 0 33Кб
Food and Related Products
Sushi
Sushi, or sushi (Jap. すし, 寿司, 壽司, 鮨, 鮓, 寿斗, 寿し sushi, [sɯɕi]; Indeclinable), is a dish of...
От FWhoop Xelqua 2023-04-26 17:00:48 0 18Кб
Programming
Create AI with Python
If you’re just starting out in the artificial intelligence (AI) world, then Python is a...
От Jesse Thomas 2023-05-01 19:27:14 0 11Кб
Marketing and Advertising
How Do Ads Make Money?
Advertising is one of the largest industries in the world, generating hundreds of billions of...
От Dacey Rankins 2026-01-05 23:54:49 0 3Кб
Business
Organizing Chart: Hats and What's Underneath?
Do we really need structure... It is good if everything works smoothly in the company: work...
От Dacey Rankins 2024-09-23 14:40:42 0 15Кб

BigMoney.VIP Powered by Hosting Pokrov