Encoding and Decoding Base64 Strings in Python

0
10K

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)
Zoeken
Categorieën
Read More
Homemaking
Pottery / Do-it-yourself ceramics
What ceramics are made of and where to get materials for workCeramics is baked clay, which is the...
By FWhoop Xelqua 2023-04-20 18:53:47 0 14K
Mental Health
ADHD: Non-stimulants
There are a number of non-stimulant medications, such as Viloxazine, atomoxetine, bupropion,...
By Kelsey Rodriguez 2023-05-01 20:22:34 0 8K
Business
DIGITALIZATION AND INNOVATION IN THE FINANCIAL SECTOR: CURRENT TRENDS AND PROSPECTS
DIGITALIZATION AND INNOVATION IN THE FINANCIAL SECTOR: CURRENT TRENDS AND PROSPECTS Abstract:...
By Leonard Pokrovski 2024-08-11 14:58:46 0 12K
Business
Advertising on billboards: how to attract attention and increase sales
Advertising on billboards: how to attract attention and increase salesAdvertising on billboards...
By Dacey Rankins 2024-09-16 14:27:22 0 14K
Personal Finance
How to make a budget for yourself
What will you learn?   What is budgeting?   What budgeting...
By FWhoop Xelqua 2022-10-11 11:52:48 0 22K
image/svg+xml


BigMoney.VIP Powered by Hosting Pokrov