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)
Поиск
Категории
Больше
Социальные проблемы
Американская история Икс. American History X (1998)
Лидер местной банды скинхедов Дерек Виньярд прочно удерживает авторитет в своём районе....
От Nikolai Pokryshkin 2022-11-29 10:39:05 0 53Кб
Life Issues
Intimacy. (2001)
A failed London musician meets once a week with a woman for a series of intense sexual encounters...
От Leonard Pokrovski 2023-05-23 16:49:21 0 38Кб
Productivity
How does minimalism improve mental health?
How Does Minimalism Improve Mental Health? Minimalism is often misunderstood as a purely...
От Michael Pokrovski 2026-04-18 05:43:28 0 8Кб
Business
What Is a Diploma in Office Administration?
A diploma in office administration is a formal educational program designed to provide students...
От Dacey Rankins 2026-04-21 17:23:03 0 4Кб
Business
What Kind of Insurance Do I Need?
When it comes to protecting your assets, securing the right kind of insurance is vital for...
От Dacey Rankins 2025-02-05 15:42:06 0 17Кб

BigMoney.VIP Powered by Hosting Pokrov