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
Научная фантастика и фэнтези
Властелин колец: Две крепости. The Lord of the Rings: The Two Towers. (2002)
Братство распалось, но Кольцо Всевластья должно быть уничтожено. Фродо и Сэм вынуждены довериться...
By Nikolai Pokryshkin 2022-11-10 10:38:15 0 37K
Programming
Python Tips
Getting a "f-string expression part cannot include a backslash" Synatx error? You can create a...
By Jesse Thomas 2023-02-14 21:54:58 0 11K
Personal Finance
What Is a Good Salary?
What Is a Good Salary? Evaluating $70k, $50k, and Income Across Different Cities and Situations...
By Leonard Pokrovski 2025-11-27 18:53:29 0 2K
Regalos
Birthday gifts to get for someone you know!
My next birthday was approaching. Based on the experience of past years, I decided to change the...
By FWhoop Xelqua 2022-09-24 19:18:28 0 33K
Business
What’s Involved in Managing a Product’s Entire Lifecycle?
Every product, like a living organism, has a lifecycle. It begins with an idea, grows through...
By Dacey Rankins 2025-08-18 13:29:06 0 4K

BigMoney.VIP Powered by Hosting Pokrov