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)
البحث
الأقسام
إقرأ المزيد
Социальные проблемы
Последний Парадизо. The Last Paradiso. (2021)
Италия, 1950-е.Свободолюбивый фермер борется за лучшие условия труда.Он мечтает о любви,...
بواسطة Nikolai Pokryshkin 2022-09-16 18:07:46 0 22كيلو بايت
Business
LG launches Native Screensaver Ads. What is it?
The American company LG Ad Solutions, a division of the South Korean giant - the manufacturer of...
بواسطة Dacey Rankins 2024-09-18 17:35:52 0 15كيلو بايت
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 14كيلو بايت
Electronics and Electrical
Types of Computers
Types of Computers Computers are distinguished by a variety of criteria, which are related to...
بواسطة Leonard Pokrovski 2024-03-19 12:23:46 0 28كيلو بايت
Business
What Legal Structures Are Suitable for a Social Enterprise?
Choosing the right legal structure is a critical decision for any social enterprise. Unlike...
بواسطة Dacey Rankins 2025-04-16 17:09:40 0 5كيلو بايت
image/svg+xml


BigMoney.VIP Powered by Hosting Pokrov