Encoding and Decoding Base64 Strings in Python

0
13K

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)
Căutare
Categorii
Citeste mai mult
Научная фантастика и фэнтези
Тёмный рыцарь: Возрождение легенды. The Dark Knight Rises. (2012)
Восемь лет назад Бэтмен растворился в ночи, превратившись из героя в беглеца. Приняв на себя вину...
By Nikolai Pokryshkin 2022-12-25 10:15:19 0 29K
Business
How Do I Attract and Retain Donors?
Attracting and retaining donors is one of the most important aspects of running a successful...
By Dacey Rankins 2025-03-26 16:34:08 0 9K
Office Products
Office Tools
Choosing office suppliesIs it time to stock up on office stationery? Not sure where to start?...
By FWhoop Xelqua 2023-03-25 16:24:05 0 24K
Business
How Will We Track Progress and Report Performance? Using Gantt, Kanban, Charts, KPIs, Dashboards, and Status Reports
Tracking project progress and reporting performance are essential for keeping teams aligned,...
By Dacey Rankins 2025-07-14 14:45:38 0 6K
Business
How Startup Innovation Is Changing the Market: Success Stories and Tools for Leaders
How Startup Innovation Is Changing the Market: Success Stories and Tools for Leaders...
By Leonard Pokrovski 2024-07-27 13:19:25 0 30K

BigMoney.VIP Powered by Hosting Pokrov