Encoding and Decoding Base64 Strings in Python

0
13Кб

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)
Поиск
Категории
Больше
Financial Services
How the AD/AS model incorporates growth, unemployment, and inflation
Key points The aggregate demand/aggregate supply, or AD/AS, model is one of the...
От Mark Lorenzo 2023-03-31 19:57:02 0 14Кб
Science Fiction and Fantasy
Interstellar. (2014)
A team of explorers travel through a wormhole in space in an attempt to ensure humanity's...
От Leonard Pokrovski 2022-11-20 21:07:02 0 26Кб
Marketing and Advertising
Can You Really Make Money With MLM?
Introduction Multilevel marketing (MLM) promises something deeply appealing — the chance...
От Dacey Rankins 2025-10-20 17:05:33 0 5Кб
Business
What Is Closing the Sale?
Introduction In sales, marketing, business development, and even partnership negotiations, there...
От Dacey Rankins 2025-11-19 19:13:27 0 2Кб
Искусство, культура и развлечения
Новый кинотеатр «Парадизо». Cinema Paradiso. (1988)
Это рассказ о счастливых днях, когда итальянское кино еще не знало о том, что такое «кризис...
От Nikolai Pokryshkin 2022-12-09 12:46:05 0 30Кб

BigMoney.VIP Powered by Hosting Pokrov