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)
Поиск
Категории
Больше
Телевидение
Телеканал 360° прямой эфир.
Самые свежие новости страны и мира 24 часа в сутки. На нашем канале кадры с места событий,...
От Nikolai Pokryshkin 2022-11-21 21:07:17 0 37Кб
Business
What Are Common Negotiation Strategies or Styles?
Negotiation is not a one-size-fits-all skill. The strategy or style chosen can profoundly impact...
От Dacey Rankins 2025-11-27 17:55:53 0 3Кб
Жизненные вопросы
Унесенные призраками. Spirited Away. (2001)
Тихиро с мамой и папой переезжает в новый дом. Заблудившись по дороге, они оказываются в странном...
От Nikolai Pokryshkin 2022-11-24 20:18:50 0 28Кб
Personal Organization
Social work
Social work with the elderly in the UNITED STATES In the United States, the implementation of...
От FWhoop Xelqua 2023-01-21 17:55:34 0 25Кб
Financial Services
Market equilibrium
Key points Supply and demand curves intersect at the equilibrium price. This is the...
От Mark Lorenzo 2023-02-10 14:23:05 0 16Кб

BigMoney.VIP Powered by Hosting Pokrov