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)
Rechercher
Catégories
Lire la suite
История
Моё тело вас закопает. My Body Will Bury You. (2021)
1860 год. Накануне объединения Италии в единое королевство южную часть полуострова наводнили...
Par Nikolai Pokryshkin 2022-09-11 21:25:00 0 24KB
Business
What Strategies Can Help in Transitioning Back to Office Work?
As businesses around the world transition back to office work after an extended period of remote...
Par Dacey Rankins 2025-01-30 15:54:30 0 9KB
Stories
The General. (1926)
After being rejected by the Confederate military, not realizing it was due to his crucial...
Par Leonard Pokrovski 2023-03-27 19:27:34 0 23KB
Programming
Python Regex
A RegEx, or Regular Expression, is a sequence of characters that forms a search...
Par Jesse Thomas 2023-04-05 19:02:13 0 10KB
Телевидение
World Fashion Channel Live TV.
World Fashion Channel – это международный телеканал о современных тенденциях в индустрии...
Par Nikolai Pokryshkin 2022-11-01 08:49:23 0 29KB

BigMoney.VIP Powered by Hosting Pokrov