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)
البحث
الأقسام
إقرأ المزيد
Научная фантастика и фэнтези
ВАЛЛ-И. WALL·E (2008)
Робот ВАЛЛ·И из года в год прилежно трудится на опустевшей Земле, очищая нашу планету от...
بواسطة Nikolai Pokryshkin 2022-12-14 10:18:15 0 36كيلو بايت
Finance
What Is Foreclosure?
What Is Foreclosure? Foreclosure is a legal process that occurs when a homeowner fails to make...
بواسطة Leonard Pokrovski 2025-10-05 19:27:12 0 5كيلو بايت
Marketing and Advertising
What Is the Minimum Budget for Google AdWords?
One of the first questions new advertisers ask is: “What is the minimum budget for Google...
بواسطة Dacey Rankins 2026-01-12 13:30:00 0 1كيلو بايت
СМИ
В случае убийства набирайте «М». Dial M for Murder. (1954)
Тони Вендис, бывший плейбой и звезда большого тенниса, прожигающий деньги своей красавицы-жены...
بواسطة Nikolai Pokryshkin 2023-03-06 15:23:34 0 30كيلو بايت
Научная фантастика и фэнтези
Мстители: Война бесконечности. Avengers: Infinity War. (2018)
Пока Мстители и их союзники продолжают защищать мир от различных опасностей, с которыми не смог...
بواسطة Nikolai Pokryshkin 2022-12-17 20:45:04 0 49كيلو بايت

BigMoney.VIP Powered by Hosting Pokrov