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)
Search
Categories
Read More
Money
How Many Credit Cards Should I Have?
How Many Credit Cards Should I Have? Credit cards can be powerful financial tools when used...
By Leonard Pokrovski 2025-09-30 22:45:50 0 5K
Business
Text of the scientific work on the topic "STRENGTHENING OPERATIONAL EFFICIENCY THROUGH INTERNAL MARKETING STRATEGIES IN THE ORGANIZATION"
Text of the scientific work on the topic "STRENGTHENING OPERATIONAL EFFICIENCY THROUGH INTERNAL...
By Leonard Pokrovski 2024-08-01 22:15:55 0 21K
Телевидение
Белорецкая телекомпания (БТК). Прямой эфир.
Телевидение города Белорецка. Новости Белорецка на русском языке. Для просмотра телеканала за...
By Nikolai Pokryshkin 2022-10-23 12:25:51 0 28K
Kids and Teens
Navigating the Challenges: Understanding Teen Struggles in 2024
In the ever-evolving landscape of adolescence, the challenges facing teenagers in 2024 are as...
By Dacey Rankins 2024-04-29 13:01:04 0 17K
Научная фантастика и фэнтези
Индиана Джонс и последний крестовый поход. Indiana Jones and the Last Crusade. (1989)
На этот раз бесстрашный Индиана разыскивает самую таинственную реликвию в истории человечества...
By Nikolai Pokryshkin 2023-02-01 11:05:49 0 28K

BigMoney.VIP Powered by Hosting Pokrov