Encoding and Decoding Base64 Strings in Python

0
13K

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
Social Issues
Mr. Smith Goes to Washington. (1939)
A naive youth leader is appointed to fill a vacancy in the U.S. Senate. His idealistic plans...
Por Leonard Pokrovski 2023-04-05 14:54:34 0 28K
Marketing and Advertising
Advanced YouTube and Digital Marketing Integration: Long-Term Growth and Brand Mastery
1. YouTube as a Strategic Asset, Not a Tool YouTube should never be treated as just another...
Por Dacey Rankins 2025-11-13 17:13:48 0 11K
Public Health and Safety
Public health management is the process of managing a complex system
Public health management is the process of managing a complex system Public health is the...
Por Leonard Pokrovski 2024-04-19 00:45:25 0 17K
Money
How to Increase Your Credit Score
How to Increase Your Credit Score A strong credit score can open doors to better loan rates,...
Por Leonard Pokrovski 2025-09-20 16:34:35 0 6K
Социальные проблемы
Крестный отец. The Godfather. (1972)
Криминальная сага, повествующая о нью-йоркской сицилийской мафиозной семье Корлеоне. Фильм...
Por Nikolai Pokryshkin 2022-10-25 11:42:13 0 38K

BigMoney.VIP Powered by Hosting Pokrov