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
Mental Health
Autism Spectrum: Diagnosis Pt. 2
Ideally the diagnosis of ASD should be given by a team of clinicians (e.g. pediatricians, child...
Por Kelsey Rodriguez 2023-03-03 18:22:53 0 12K
Business
Why doesn't Mark Zuckerberg control Facebook and Instagram ads?
A bipartisan group of 19 US lawmakers sent a letter to the CEO of Meta  Mark Zuckerberg, in...
Por Dacey Rankins 2024-09-17 20:42:52 0 15K
Computer Science
Computer Science
Informatics is the science of methods and processes of collecting, storing,...
Por Michael Pokrovski 2024-03-21 23:29:27 0 27K
Antiques and Collectibles
A Guide to Shopping for Antiques and Collectibles: Tips for Finding Timeless Treasures
Shopping for antiques and collectibles is a thrilling journey that combines history, artistry,...
Por Dacey Rankins 2024-11-29 15:08:02 0 10K
Business
How Do You Create or Develop a Product Strategy?
A well-crafted product strategy is the cornerstone of every successful product. Without it, teams...
Por Dacey Rankins 2025-08-21 16:33:32 0 4K

BigMoney.VIP Powered by Hosting Pokrov