Encoding and Decoding Base64 Strings in Python

0
12K

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
14 Celebrities Who Have Succeeded in Business
In 2023, singer Rihanna, who is already on the Forbes lists, decided to expand the brand line of...
Por Dacey Rankins 2024-07-24 12:09:25 0 13K
Жизненные вопросы
Один раз живём. Si vive una volta sola. (2021)
Команда врачей и, по совместительству, друзей, узнаёт, что коллега смертельно болен. Результаты...
Por Nikolai Pokryshkin 2022-09-16 22:30:52 0 28K
Business
How Do I Start a Career in Project Management?
Project management is a dynamic and rewarding career that involves leading teams, managing...
Por Dacey Rankins 2025-05-16 14:43:22 0 7K
Animation
Oshi no Ko: Why you should watch it
Oshi no Ko: What the Hot New Anime is About and Why You Should Watch It“Oshi no Ko”...
Por FWhoop Xelqua 2023-05-07 20:06:55 0 25K
Financial Services
Market equilibrium
Key points Supply and demand curves intersect at the equilibrium price. This is the...
Por Mark Lorenzo 2023-06-30 19:04:23 0 12K

BigMoney.VIP Powered by Hosting Pokrov