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)
Buscar
Categorías
Read More
СМИ
В случае убийства набирайте «М». Dial M for Murder. (1954)
Тони Вендис, бывший плейбой и звезда большого тенниса, прожигающий деньги своей красавицы-жены...
By Nikolai Pokryshkin 2023-03-06 15:23:34 0 18K
Arts, Culture and Entertainment
Ma Rainey's Black Bottom (2020)
Late to the session, the fearless, fiery Ma engages in a battle of wills with her white manager...
By Leonard Pokrovski 2022-09-27 14:44:34 0 21K
Mental Health
Psychosis: Causes Pt.2
Psychiatric disordersFrom a diagnostic standpoint, organic disorders were believed to be caused...
By Kelsey Rodriguez 2023-05-25 18:55:36 0 6K
Science Fiction and Fantasy
The Lord of the Rings: The Fellowship of the Ring.(2001)
A meek Hobbit from the Shire and eight companions set out on a journey to destroy the powerful...
By Leonard Pokrovski 2022-11-07 19:54:46 0 18K
Financial Services
How to establish an emergency savings fund
Establishing an emergency savings fund now can have a big payoff later. Setting aside emergency...
By Mark Lorenzo 2023-05-17 20:13:55 0 10K
image/svg+xml


BigMoney.VIP Powered by Hosting Pokrov