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)
Поиск
Категории
Больше
Homeowners
How to rent an apartment - features of finding a tenant and common mistakes of landlords
Renting out an apartment is one of the ways to generate income for property owners. It seems that...
От FWhoop Xelqua 2023-01-18 13:24:48 0 24Кб
Programming
Python Asyncio wait_for()
You can wait for an asyncio task or coroutine to complete with a timeout using...
От Jesse Thomas 2023-03-30 21:54:41 0 12Кб
Personal Finance
How to make a budget for yourself
What will you learn?   What is budgeting?   What budgeting...
От FWhoop Xelqua 2022-10-11 11:52:48 0 26Кб
Социальные проблемы
Олдбой. Oldboy. (2003)
1988 год. Обыкновенный и ничем непримечательный бизнесмен О Дэ-cу в день трёхлетия дочери по пути...
От Nikolai Pokryshkin 2022-12-26 12:04:09 0 29Кб
Business
Starting a Business: A Step-by-Step Guide
Starting a business can be an exciting yet challenging endeavor. Whether you're pursuing your...
От Dacey Rankins 2024-12-16 13:55:43 0 15Кб

BigMoney.VIP Powered by Hosting Pokrov