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)
Buscar
Categorías
Read More
Graphic Design
Evolution and Importance of Graphic Design
Graphic design is an ever-evolving field that combines art and technology to communicate ideas...
By Dacey Rankins 2024-10-08 22:41:19 0 17K
Социальные проблемы
Храброе сердце. Braveheart. (1995)
Действие фильма начинается в 1280 году в Шотландии. Это история легендарного национального героя...
By Nikolai Pokryshkin 2023-01-01 18:28:38 0 22K
News and Media
News and Media: Navigating a Changing Landscape
The news and media industry has undergone a dramatic transformation in the digital age. From the...
By Dacey Rankins 2024-10-16 16:08:27 0 18K
Science Fiction and Fantasy
The Incredibles. (2004)
While trying to lead a quiet suburban life, a family of undercover superheroes are forced into...
By Leonard Pokrovski 2023-06-22 20:52:18 0 36K
Personal Finance
What Other Costs Come With Taking Out a Mortgage?
What Other Costs Come With Taking Out a Mortgage? For many people, buying a home is the largest...
By Leonard Pokrovski 2025-11-14 21:39:08 0 1K

BigMoney.VIP Powered by Hosting Pokrov