Encoding and Decoding Base64 Strings in Python

0
13KB

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
Социальные проблемы
Мясо и кровь. Wildland. (2020)
Ида, после гибели своей матери в автокатастрофе, переезжает жить к своей тёте и двоюродным...
Por Nikolai Pokryshkin 2022-10-19 17:58:26 0 26KB
Financial Services
Your 401(k): 10 things to find out
1. When can I start contributing? Not every 401(k) plan allows new employees to begin...
Por Mark Lorenzo 2023-05-25 18:45:54 0 11KB
Hand Games
16 of the best games of our childhood that we lost
In the XXI century, children quietly disappeared from the courtyards of large cities - now they...
Por FWhoop Xelqua 2022-11-14 10:59:43 0 32KB
Supercomputing
Supercomputing: Unleashing the Power of Advanced Computing
Supercomputing represents the pinnacle of computational capability, enabling researchers and...
Por Dacey Rankins 2024-10-21 16:45:44 0 13KB
Social Issues
Capone. (2020)
After serving 10 years in prison, Al Capone is released to live in exile in Florida. Deprived of...
Por Leonard Pokrovski 2022-10-22 19:27:41 0 26KB

BigMoney.VIP Powered by Hosting Pokrov