Encoding and Decoding Base64 Strings in Python

0
13KB

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
Business
How Do I Measure the Success of a Business Strategy?
  How Do I Measure the Success of a Business Strategy?...
Por Dacey Rankins 2024-12-25 18:21:34 0 14KB
Finance
Relationship with money
Relationships with money are one of the areas of life that is strongly charged with projections....
Por Dacey Rankins 2024-10-04 15:33:27 0 11KB
Programming
Display Data from Python to HTML
When making a web application, you're probably thinking if displaying data from Python to HTML is...
Por Jesse Thomas 2023-01-26 19:18:03 0 13KB
Astronomy
Unlocking the Mysteries of the Cosmos: A Journey into Astronomy
Unlocking the Mysteries of the Cosmos: A Journey into Astronomy Astronomy, the oldest of the...
Por Leonard Pokrovski 2024-05-22 20:23:10 0 19KB
Finance
Life and Investment Lessons from Warren Buffett, George Soros, and Other Famous Financiers
Life and Investment Lessons from Warren Buffett, George Soros, and Other Famous Financiers Few...
Por Leonard Pokrovski 2025-10-07 22:01:07 0 3KB

BigMoney.VIP Powered by Hosting Pokrov