Encoding and Decoding Base64 Strings in Python

0
14KB

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)
Pesquisar
Categorias
Leia mais
Public Health and Safety
Public health management is the process of managing a complex system
Public health management is the process of managing a complex system Public health is the...
Por Leonard Pokrovski 2024-04-19 00:45:25 0 19KB
Music
The Power of Music: A Universal Language
Music is often described as a universal language, transcending borders, cultures, and languages....
Por Dacey Rankins 2024-11-07 19:13:56 0 14KB
Productivity
How do I focus when studying?
How Do I Focus When Studying? Focusing while studying is one of the most important cognitive...
Por Michael Pokrovski 2026-04-18 06:26:08 0 2KB
Programming
Python roblox-aio.py
roblox-aio.py is a Python Roblox API wrapper library that will have many features in the future....
Por Jesse Thomas 2023-04-27 21:25:51 0 12KB
Economics
What Is the Global Economy?
What Is the Global Economy? The modern man wakes up in a bed assembled from Malaysian rubber,...
Por Leonard Pokrovski 2026-05-15 20:10:23 0 663

BigMoney.VIP Powered by Hosting Pokrov