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)
البحث
الأقسام
إقرأ المزيد
Социальные проблемы
Гражданин Кейн. Citizen Kane. (1941)
В шикарном поместье умирает газетный магнат Чарльз Фостер Кейн, роняя лишь одно слово:...
بواسطة Nikolai Pokryshkin 2023-01-14 11:42:04 0 34كيلو بايت
Personal Finance
What Is Debt?
What Is Debt? Debt is a fundamental part of modern finance and economics. It influences how...
بواسطة Leonard Pokrovski 2025-10-28 16:29:35 0 2كيلو بايت
Business
What Moment Shaped Me Most?
Life is often described as a journey, and along that journey there are moments—sometimes...
بواسطة Dacey Rankins 2025-09-09 14:17:09 0 3كيلو بايت
Business
What Are Common Challenges Faced by Startup CEOs?
Being a startup CEO is a high-stakes, high-pressure role filled with constant decision-making,...
بواسطة Dacey Rankins 2025-05-05 14:57:10 0 9كيلو بايت
Life Issues
Shutter Island. (2010)
In 1954, a U.S. Marshal investigates the disappearance of a murderer who escaped from a hospital...
بواسطة Leonard Pokrovski 2023-02-16 13:03:05 1 24كيلو بايت

BigMoney.VIP Powered by Hosting Pokrov