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)
Pesquisar
Categorias
Leia Mais
Programming
Python setup.py
setup.py is a python file, the presence of which is an indication that the module/package...
Por Jesse Thomas 2023-04-26 21:12:26 0 13K
Life Issues
Inception (2010)
A thief who steals corporate secrets through the use of dream-sharing technology is given the...
Por Leonard Pokrovski 2022-11-12 20:59:30 0 25K
Mental Health
Autism Spectrum: Social and Communication skills
In social contexts, autistic people may respond and behave differently than individuals without...
Por Kelsey Rodriguez 2023-02-15 17:58:48 0 13K
Business
How Do I Market My Business on a Low Budget?
Marketing is essential for growing a business, but not every entrepreneur has a big budget for...
Por Dacey Rankins 2025-03-14 16:12:04 0 11K
Finance
Which Finance Biographies Include Personal Struggles and Failures?
Which Finance Biographies Include Personal Struggles and Failures? Finance biographies often...
Por Leonard Pokrovski 2025-10-08 20:38:18 0 2K

BigMoney.VIP Powered by Hosting Pokrov