Encoding and Decoding Base64 Strings in Python

0
14χλμ.

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)
Αναζήτηση
Κατηγορίες
Διαβάζω περισσότερα
Golf
The Timeless Appeal of Golf: A Sport that Challenges and Inspires
Golf, often referred to as the "gentleman's game," holds a unique place in the world of sports....
από Dacey Rankins 2024-06-26 19:56:34 0 16χλμ.
Accounting
Collection of jokes about accountants and programmers
Collection of jokes about accountants and programmers Start the morning with a humorous...
από Leonard Pokrovski 2024-03-11 21:36:46 0 30χλμ.
История
Моё тело вас закопает. My Body Will Bury You. (2021)
1860 год. Накануне объединения Италии в единое королевство южную часть полуострова наводнили...
από Nikolai Pokryshkin 2022-09-11 21:25:00 0 27χλμ.
Music
5 Calming Meditation Music for Deep Relaxation, Focus, and Inner Peace
In today’s fast-paced world, finding a moment of peace can feel like chasing a moving...
από Gpykin 2025-07-05 17:54:19 0 21χλμ.
Travel
Named the most visited attractions in the world
The authoritative publication Travel + Leisure has published a list of the main tourist...
από FWhoop Xelqua 2023-01-03 14:47:15 0 23χλμ.

BigMoney.VIP Powered by Hosting Pokrov