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
Business
How Do I Get Customers and Deliver Value?
One of the biggest challenges entrepreneurs face isn't just building a product—it's...
Por Dacey Rankins 2025-04-30 12:55:59 0 14KB
Life Issues
Shutter Island. (2010)
In 1954, a U.S. Marshal investigates the disappearance of a murderer who escaped from a hospital...
Por Leonard Pokrovski 2023-02-16 13:03:05 1 24KB
Жизненные вопросы
Земляничная поляна. Wild Strawberries. (1957)
78-летний профессор из Стокгольма вспоминает и пересматривает разочарования своей долгой жизни....
Por Nikolai Pokryshkin 2023-03-26 13:25:00 0 30KB
Money
Money to Money: How to Learn to Save Correctly
A new smartphone, fashionable sneakers, studying at a prestigious university or traveling around...
Por Dacey Rankins 2024-10-22 16:11:07 0 15KB
Personal Finance
How Do I Qualify for a Mortgage?
How Do I Qualify for a Mortgage? Understanding Credit Score Requirements, Income, Employment...
Por Leonard Pokrovski 2025-11-14 21:38:16 0 7KB

BigMoney.VIP Powered by Hosting Pokrov