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)
البحث
الأقسام
إقرأ المزيد
История
Хороший, плохой, злой. The Good, the Bad and the Ugly. (1966)
В разгар гражданской войны таинственный стрелок скитается по просторам Дикого Запада. У него нет...
بواسطة Nikolai Pokryshkin 2022-11-05 20:26:12 0 38كيلو بايت
Marketing and Advertising
What Is an Advertising Biography?
Advertising is often associated with campaigns, brands, slogans, and visuals—but behind...
بواسطة Dacey Rankins 2026-01-07 14:18:48 0 3كيلو بايت
Reference
Scientific electronic resources
Scopusis the world's largest unified abstract and scientometric database (citation index), which...
بواسطة FWhoop Xelqua 2022-11-15 12:39:30 0 28كيلو بايت
Business
How Do I Pitch to Clients?
1. What Does It Mean to Pitch to Clients? A client pitch is a conversation or presentation...
بواسطة Dacey Rankins 2025-12-02 20:13:48 0 5كيلو بايت
Television
Catholic TV Live USA
CatholicTV is a beacon of Hope and a unique Herald of the simple, yet profound Message of Jesus...
بواسطة Nikolai Pokryshkin 2022-08-31 21:23:50 0 40كيلو بايت

BigMoney.VIP Powered by Hosting Pokrov