Encoding and Decoding Base64 Strings in Python

0
13K

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)
Search
Categories
Read More
Business
Drew Houston
Drew Houston Drew Houston Andrew W. "Drew" Houston   Date of...
By Leonard Pokrovski 2024-08-16 14:54:55 0 24K
Социальные проблемы
В порту. On the Waterfront. (1954)
В центре сюжета судьба простого докера - Терри Мэллоу, терзающегося сомнениями и решающего встать...
By Nikolai Pokryshkin 2023-03-22 18:01:54 0 36K
Financial Services
Using a person's budget to understand the balance of payments
To get a better understanding of the balance of payments accounts, let’s think of a...
By Mark Lorenzo 2023-03-09 18:06:55 0 13K
Television
GBN Classic, Live TV. Southaven, Mississippi, United States.
Gospel Broadcasting Network is a non-profit organization that provides Bible-based and unbiased...
By Nikolai Pokryshkin 2022-09-26 12:21:45 0 42K
Marketing and Advertising
How Does B2C Marketing Differ from B2B Marketing?
Marketing is not one-size-fits-all. While many principles overlap, B2C (Business-to-Consumer) and...
By Dacey Rankins 2025-09-20 16:38:55 0 3K

BigMoney.VIP Powered by Hosting Pokrov