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
Научная фантастика и фэнтези
Индиана Джонс и последний крестовый поход. Indiana Jones and the Last Crusade. (1989)
На этот раз бесстрашный Индиана разыскивает самую таинственную реликвию в истории человечества...
By Nikolai Pokryshkin 2023-02-01 11:05:49 0 27K
Social Issues
The Green Mile. (1999)
The lives of guards on Death Row are affected by one of their charges: a black man accused of...
By Leonard Pokrovski 2022-11-21 20:14:20 0 22K
Religion and spirituality
The Only Video You Need to Start Manipulating Energy RIGHT NOW! (full guide)
In the video titled "The Only Video You Need to Start Manipulating Energy," published on February...
By Nikolai Pokrovski 2025-02-15 22:29:07 0 13K
Financial Services
The benefits and costs of US environmental laws
Key points Taken as a whole, the benefits of US environmental regulation have...
By Mark Lorenzo 2023-02-20 17:47:53 0 11K
Business
What Are Examples of Successful Business Strategies?
In the ever-changing landscape of business, companies need to adopt strategies that ensure...
By Dacey Rankins 2024-12-25 18:15:29 0 12K

BigMoney.VIP Powered by Hosting Pokrov