Encoding and Decoding Base64 Strings in Python

0
11KB

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
Life Issues
To Kill a Mockingbird. (1962)
Atticus Finch, a widowed lawyer in Depression-era Alabama, defends a black man against an...
Por Leonard Pokrovski 2023-01-24 14:39:42 0 19KB
Picture Ratings
The Art and Science of Picture Ratings: Understanding Recreation Through Visual Evaluation
The Art and Science of Picture Ratings: Understanding Recreation Through Visual Evaluation In...
Por Leonard Pokrovski 2024-05-14 22:46:47 0 16KB
Business
How do I find my first customers?
Every startup starts with zero customers. The first few are the hardest to get—but...
Por Dacey Rankins 2025-04-11 16:58:52 0 6KB
Medicine
Medication
Medication Lekárstvennyj...
Por Leonard Pokrovski 2024-04-16 19:27:09 0 13KB
Спорт
Морской заговор: Тайна устойчивого рыболовства. Seaspiracy. (2021)
Все документальные события данного кинофильма от Netflix, который имеет название "Морской...
Por Nikolai Pokryshkin 2022-09-11 23:33:17 0 31KB

BigMoney.VIP Powered by Hosting Pokrov