Encoding and Decoding Base64 Strings in Python

0
6كيلو بايت

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)
البحث
الأقسام
إقرأ المزيد
الوقت
Time
Time is the continued sequence of existence and events that occurs in an apparently irreversible...
بواسطة FWhoop Xelqua 2022-09-07 13:48:10 0 22كيلو بايت
Cycling
The Thrill and Endurance of Cycling Sports: A Journey on Two Wheels
  The Thrill and Endurance of Cycling Sports: A Journey on Two Wheels...
بواسطة Leonard Pokrovski 2024-06-20 04:16:56 0 13كيلو بايت
Жизненные вопросы
Гран Торино. Gran Torino. (2008)
Вышедший на пенсию автомеханик Уолт Ковальски проводит дни, починяя что-то по дому, попивая пиво...
بواسطة Nikolai Pokryshkin 2023-03-13 18:57:52 0 16كيلو بايت
Finance
Top 8 Most Expensive Currencies in the World - 2024 Ranking
The size of inflation and interest rates, the scale of unemployment, GDP, fluctuations in stock...
بواسطة Dacey Rankins 2024-10-22 17:31:36 0 6كيلو بايت
القصص
13th (2016)
An in-depth look at the prison system in the United States and how it reveals the nation's...
بواسطة Leonard Pokrovski 2023-07-11 20:31:04 0 16كيلو بايت
image/svg+xml


BigMoney.VIP Powered by Hosting Pokrov