Encoding and Decoding Base64 Strings in Python

0
12K

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
Телевидение
12 Омское областное телевидение. Прямой эфир.
12 канал — единственная региональная телекомпания, осуществляющая собственное...
By Nikolai Pokryshkin 2022-10-07 18:24:16 0 39K
Arts, Culture and Entertainment
Annette. (2021)
Los Angeles, nowadays. Henry is a stand-up comedian with a fierce humor. Ann, an internationally...
By Nikolai Pokryshkin 2022-09-01 20:11:00 1 41K
Business
What Skills Does a Project Manager Need? Leadership, Communication, Negotiation, Budgeting, Risk Management
A project manager is more than a scheduler or coordinator—they are the strategic driver who...
By Dacey Rankins 2025-07-15 16:00:54 0 4K
Ask an Expert
10 mistakes that will kill your expert video
Many experts make these mistakes and lose their audience. But they are easy to avoid - I have put...
By FWhoop Xelqua 2022-10-02 12:01:16 0 41K
Business
How Can a Solopreneur Manage Financial Aspects of Their Business?
As a solopreneur, managing the financial aspects of your business is essential for long-term...
By Dacey Rankins 2025-02-13 16:36:24 0 11K

BigMoney.VIP Powered by Hosting Pokrov