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)
Поиск
Категории
Больше
Programming
Python SlowAPI
SlowAPI is a ratelimiter library for FastAPI and Starlette adapted from flask-limiter. This...
От Jesse Thomas 2023-04-12 18:06:14 0 12Кб
Искусство, культура и развлечения
Мадам Парфюмер. Perfumes. (2020)
Анна Вальберг — знаменитость в мире парфюмерии. Она живет как дива, ведет себя как эгоистка...
От Nikolai Pokryshkin 2022-09-30 21:26:20 0 30Кб
Decision Making and Problem Solving
What is problem solving?
You stare blankly at a complex, multifaceted systems failure flashing across your dashboard...
От Michael Pokrovski 2026-07-29 17:32:26 0 564
Marketing and Advertising
How Often Do Digital Billboards Change Ads?
Digital billboards have transformed outdoor advertising by allowing multiple advertisers to share...
От Dacey Rankins 2026-01-15 17:24:31 0 5Кб
Productivity
Can focus be trained like a muscle?
Can Focus Be Trained Like a Muscle? The idea that “focus is like a muscle” has...
От Michael Pokrovski 2026-04-18 06:10:49 0 23Кб

BigMoney.VIP Powered by Hosting Pokrov