Encoding and Decoding Base64 Strings in Python

0
14K

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
Programming
Python Spotipy
Spotipy is a lightweight Python library for the Spotify Web API. With Spotipy you...
By Jesse Thomas 2023-04-18 21:46:28 0 12K
Business
What Are Common Mistakes When Giving Feedback?
Feedback is one of the most powerful tools for learning and performance improvement—but...
By Dacey Rankins 2025-07-24 18:02:20 0 5K
Economics
Can the UK rejoin the EU after Brexit?
Can the UK rejoin the EU after Brexit? Since the United Kingdom formally left the European Union...
By Leonard Pokrovski 2026-02-06 00:00:39 0 2K
Programming
Python While Loops
While loops can be ran as long as the condition is True. Otherwise, it'll be skipped. A variable...
By Jesse Thomas 2023-03-09 21:24:28 0 12K
Mental Health
ADHD: Diagnosis
ADHD is diagnosed by an assessment of a person's behavioural and mental development, including...
By Kelsey Rodriguez 2023-04-19 17:32:00 0 14K

BigMoney.VIP Powered by Hosting Pokrov