Encoding and Decoding Base64 Strings in Python

0
8K

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)
Site içinde arama yapın
Kategoriler
Read More
Business
What is a COO?
A Chief Operating Officer (COO) is an executive responsible for overseeing the daily operations...
By Dacey Rankins 2025-01-27 18:49:03 0 3K
Financial Services
Types of market-oriented environmental tools
Key points The three main categories of market-oriented environmental policies are...
By Mark Lorenzo 2023-05-03 20:55:50 0 6K
Financial Services
8 money tips for freelance workers
If you’ve traded in your cubicle to become a freelancer, you’re not alone. Fifteen...
By Mark Lorenzo 2023-05-18 19:49:49 0 15K
Life Issues
Second Act. (2018)
A big box store worker reinvents her life and her life-story and shows Madison Avenue what street...
By Leonard Pokrovski 2023-05-28 19:17:32 0 22K
Arts, Culture and Entertainment
Rifkin's Festival (2020)
The film tells the story of an American couple attending the San Sebastian International Film...
By Leonard Pokrovski 2022-10-01 21:21:36 0 18K
image/svg+xml


BigMoney.VIP Powered by Hosting Pokrov