Encoding and Decoding Base64 Strings in Python

0
14Кб

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)
Поиск
Категории
Больше
Retail Trade
Retail
Retail trade is the business activity of selling goods or providing services directly to end...
От Dacey Rankins 2024-03-18 17:20:11 0 26Кб
Business
What Are the Components of a Good Business Plan?
A well-crafted business plan serves as a blueprint for your company’s success, whether...
От Dacey Rankins 2024-12-17 14:41:35 0 11Кб
Personal Finance
Myths and Misconceptions About Credit Repair.
Credit repair often gets a bad rap and is riddled with myths that can discourage people from...
От Dacey Rankins 2024-10-23 16:18:07 0 20Кб
Financial Services
Law of supply
Key points The law of supply states that a higher price leads to a higher...
От Mark Lorenzo 2023-06-28 19:25:37 0 16Кб
Environment
Environment
Environment What does that mean? The environment is what is around you and how it affects your...
От FWhoop Xelqua 2022-12-17 14:55:18 0 23Кб

BigMoney.VIP Powered by Hosting Pokrov