Encoding and Decoding Base64 Strings in Python

0
6K

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
Motorcycles
The Thrill of Motorcycles: A Deep Dive into Riding Culture and Innovation
Motorcycles are more than just a mode of transportation; they represent freedom, adventure, and a...
Por Dacey Rankins 2024-10-11 15:58:15 0 17K
Социальные проблемы
Аферистка. I Care a Lot. (2021)
Марла руководствуется принципом «побеждает сильнейший». Женщина организовала...
Por Nikolai Pokryshkin 2022-09-15 20:38:31 0 23K
Horror
A Quiet Place Part II. (2021)
Following the events at home, the Abbott family now face the terrors of the outside world. Forced...
Por Leonard Pokrovski 2022-09-22 14:48:07 0 29K
Colleges and Universities
Keeping Up with Higher Education: Latest News from Colleges and Universities
Keeping Up with Higher Education: Latest News from Colleges and Universities In the...
Por Leonard Pokrovski 2024-05-03 21:44:11 0 9K
Социальные проблемы
Расёмон. Rashomon. (1950)
Древняя Япония. В лесу изнасилована женщина, а её муж убит. Есть четыре точки зрения на это...
Por Nikolai Pokryshkin 2023-02-25 13:44:25 0 10K
image/svg+xml


BigMoney.VIP Powered by Hosting Pokrov