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)
Căutare
Categorii
Citeste mai mult
Earth Sciences
Understanding Earth Sciences: A Gateway to Our Planet's Past, Present, and Future
Earth sciences, also known as geosciences, encompass the study of the Earth’s structure,...
By Dacey Rankins 2024-12-11 14:55:17 0 9K
Деньги
Финансовая Энергия
Как энергия экстрасенсов работает для привлечения финансов и улучшения материального...
By Nikolai Pokrovski 2024-12-17 21:43:24 0 21K
Photography
Photography
Photography art is the photography-based art of creating a photograph that reflects the creative...
By FWhoop Xelqua 2023-07-13 19:56:40 0 23K
Personal Finance
How Do 529 Plans Work and What Are the Tax Benefits?
How Do 529 Plans Work and What Are the Tax Benefits? Saving for education is one of the biggest...
By Leonard Pokrovski 2025-12-24 18:11:26 0 390
Социальные проблемы
Поймай меня, если сможешь. Catch Me If You Can. (2002)
Фрэнк Эбегнейл успел поработать врачом, адвокатом и пилотом на пассажирской авиалинии – и...
By Nikolai Pokryshkin 2023-03-15 18:11:44 0 32K

BigMoney.VIP Powered by Hosting Pokrov