Encoding and Decoding Base64 Strings in Python

0
14KB

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)
Pesquisar
Categorias
Leia mais
История
Мост через реку Квай. The Bridge on the River Kwai. (1957)
Захваченные в плен японцами британские солдаты и их командир полковник Николсон вынуждены строить...
Por Nikolai Pokryshkin 2023-03-08 13:16:07 0 26KB
Business
How to Drive Ecommerce Growth Through Conversion Rate Optimization
How to Drive Ecommerce Growth Through Conversion Rate Optimization Think of your...
Por Leonard Pokrovski 2024-08-27 16:03:40 0 31KB
Financial Services
How changes in the cost of living are measured
Key points The Consumer Price Index, or CPI is a measure of...
Por Mark Lorenzo 2023-06-09 20:21:34 0 14KB
Finance
How Long Does It Take to Read Finance Biographies?
How Long Does It Take to Read Finance Biographies? A Look at Why They’re So Dense —...
Por Leonard Pokrovski 2025-10-08 20:59:04 0 7KB
Jewelry
The most expensive jewelry in the world
Beautiful, alluring, mystical, mysterious... precious stones have always had a special power over...
Por FWhoop Xelqua 2022-11-09 17:34:25 0 22KB

BigMoney.VIP Powered by Hosting Pokrov