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)
Поиск
Категории
Больше
Personal Finance
Why you should keep a record of your finances
First of all, personal financial planning is the most important tool not only for the...
От FWhoop Xelqua 2022-10-05 13:29:40 0 25Кб
Научная фантастика и фэнтези
Человек-паук: Через вселенные. Spider-Man: Into the Spider-Verse. (2018)
Мы всё знаем о Питере Паркере. Он спас город, влюбился, а потом спасал город снова и...
От Nikolai Pokryshkin 2022-12-22 21:20:45 0 22Кб
Деньги
What is Negative Equity?
What is Negative Equity? Negative equity is a financial situation where the value of an asset,...
От Leonard Pokrovski 2025-09-27 17:35:48 0 6Кб
Истории
The Bridge on the River Kwai. (1957)
British POWs are forced to build a railway bridge across the river Kwai for their Japanese...
От Leonard Pokrovski 2023-03-09 19:18:55 0 24Кб
Programming
Python roblox-aio.py
roblox-aio.py is a Python Roblox API wrapper library that will have many features in the future....
От Jesse Thomas 2023-04-27 21:25:51 0 11Кб

BigMoney.VIP Powered by Hosting Pokrov