Encoding and Decoding Base64 Strings in Python

0
8K

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
Телевидение
Музыкальный телеканал FreshTV
Видеоклипы звёзд российского шоу-бизнеса и молодых исполнителей всех музыкальных жанров,...
Por Nikolai Pokryshkin 2022-10-14 17:47:58 0 18K
News
Recent News Impacting Kids and Teens: Insights and Developments
Recent News Impacting Kids and Teens: Insights and Developments Keeping up with the latest news...
Por Leonard Pokrovski 2024-04-30 14:53:15 0 11K
Nursing
The Vital Role of Nursing: A Pillar of Healthcare
Nursing is a profession that embodies compassion, dedication, and expertise. Nurses are at the...
Por Dacey Rankins 2024-11-13 16:20:52 0 5K
Business
How Do I Write a Professional Business Biography?
A professional business biography is a powerful tool that provides insight into your career...
Por Dacey Rankins 2024-12-27 15:57:28 0 8K
Programming
Python Append List
To append a list, the variable must be a list type. Once the variable is a list, you can then...
Por Jesse Thomas 2023-02-21 23:16:43 0 6K
image/svg+xml


BigMoney.VIP Powered by Hosting Pokrov