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)
Zoeken
Categorieën
Read More
Financial Services
The economics of pollution
Key Points Economic production can cause environmental damage. This tradeoff...
By Mark Lorenzo 2023-04-28 19:04:10 0 7K
Телевидение
Общественное телевидение Приморья. Прямой эфир.
Общественное телевидение Приморья — главный региональный телеканал, вещающий круглосуточно...
By Nikolai Pokryshkin 2022-10-25 10:08:57 0 17K
Disabled
Navigating the Complexities of Disability in Modern Society
Navigating the Complexities of Disability in Modern Society Introduction:In the mosaic of human...
By Leonard Pokrovski 2024-06-06 18:38:08 0 13K
Financial Services
Your guide to key tax terms
1. Gross and taxable income Gross income is your total income over the course of the year....
By Mark Lorenzo 2023-05-31 19:27:37 0 7K
Mental Health
Dyslexia: Society and culture
As is the case with any disorder, society often makes an assessment based on incomplete...
By Kelsey Rodriguez 2023-07-10 17:29:57 0 7K
image/svg+xml


BigMoney.VIP Powered by Hosting Pokrov