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)
Căutare
Categorii
Citeste mai mult
Financial Services
Law of supply
Key points The law of supply states that a higher price leads to a higher...
By Mark Lorenzo 2023-04-07 20:57:24 0 12K
Business
Describe a Challenging Situation You've Faced and How You Handled It
Employers Look for Problem-Solving Skills and Resilience One of the most telling questions in an...
By Dacey Rankins 2025-06-18 14:54:01 0 9K
Aging
The secret of eternal youth. What are the causes of human aging and death?
We age for a reason, but as a result of a special biological program. But there is an African...
By Dacey Rankins 2024-04-15 19:50:05 0 16K
Социальные проблемы
Крепкий орешек. Die Hard. (1988)
В суперсовременном небоскребе Лос-Анджелеса полицейский Джон Макклейн ведет смертельную схватку с...
By Nikolai Pokryshkin 2023-01-30 12:03:10 0 24K
Business
What is the Company's Approach to Work-Life Balance?
Work-life balance has become a key consideration for employees evaluating potential employers. As...
By Dacey Rankins 2025-06-11 13:25:32 0 6K

BigMoney.VIP Powered by Hosting Pokrov