Encoding and Decoding Base64 Strings in Python

0
13كيلو بايت

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)
البحث
الأقسام
إقرأ المزيد
Technology
"James Webb" and the heart of the Milky Way: major scientific achievements
On Earth in 2022, things did not work out, and even science pleased us primarily with space news....
بواسطة FWhoop Xelqua 2022-12-31 15:35:02 0 34كيلو بايت
Mental Health
Dyslexia: Stigma and success
Due to the various cognitive processes that dyslexia affects and the overwhelming societal stigma...
بواسطة Kelsey Rodriguez 2023-07-11 18:54:34 0 11كيلو بايت
Regional
China as a global partner
The first series of broadcasts is dedicated to China. Alexey Kalinin, Vice-Rector for Research at...
بواسطة FWhoop Xelqua 2023-07-22 18:10:41 0 33كيلو بايت
Crafts
Exploring the World of Arts and Crafts: A Creative Journey
Arts and crafts have been a cherished part of human culture for centuries, blending creativity...
بواسطة Dacey Rankins 2024-11-22 14:34:26 0 11كيلو بايت
أخرى
Betting On Zero. (2016)
Writer/director Ted Braun follows controversial hedge fund titan Bill Ackman as he puts a billion...
بواسطة Leonard Pokrovski 2023-06-11 14:32:29 0 31كيلو بايت

BigMoney.VIP Powered by Hosting Pokrov