Encoding and Decoding Base64 Strings in Python

0
15Кб

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)
Поиск
Категории
Больше
Business
What Lessons or Leadership Principles Can I Learn from Their Lives?
Studying leaders offers actionable insights into decision-making, ethics, and vision. Common...
От Dacey Rankins 2025-08-13 21:15:01 0 8Кб
Reproductive Health
Reproductive Health: Understanding Its Importance for Individuals and Society
Reproductive health is a cornerstone of overall well-being, encompassing a wide range of...
От Dacey Rankins 2024-11-05 15:52:56 0 11Кб
Социальные проблемы
Рождество кота Боба. A Christmas Gift from Bob. (2020)
До встречи с котом Бобом Джеймс не любил Рождество, но рыжий пушистый хулиган всё изменил. Он в...
От Nikolai Pokryshkin 2022-10-05 17:02:02 0 31Кб
Mental Health
Psychosis: Methamphetamine
Methamphetamine induces a psychosis in 26–46 percent of heavy users. Some of these people...
От Kelsey Rodriguez 2023-06-01 20:13:12 0 11Кб
Social Issues
Trainspotting. (1996)
Renton, deeply immersed in the Edinburgh drug scene, tries to clean up and get out, despite the...
От Leonard Pokrovski 2023-03-10 19:45:23 0 25Кб

BigMoney.VIP Powered by Hosting Pokrov