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)
Поиск
Категории
Больше
Products and Shopping
10 health products that will not hit the wallet
Hello, dear readers! Today we will talk about useful products for health. As you...
От FWhoop Xelqua 2022-09-15 18:09:33 0 56Кб
Искусство, культура и развлечения
Шерлок младший. Sherlock Jr. (1924)
Б.Китон - киномеханик, который мечтает быть знаменитым детективом, как Шерлок Холмс. Влюбленный в...
От Nikolai Pokryshkin 2023-04-02 21:01:16 0 42Кб
Business and Corporate Finance
How Does a CFO Improve Profitability?
How Does a CFO Improve Profitability? Profitability is the ultimate measure of a company’s...
От Leonard Pokrovski 2026-01-15 20:21:40 0 2Кб
Business
How Can Late-Stage Startups Maintain Innovation?
As startups mature, they often face challenges in sustaining the innovation that fueled their...
От Dacey Rankins 2025-03-06 18:21:36 0 12Кб
Social Issues
The Godfather. (1972)
The Godfather "Don" Vito Corleone is the head of the Corleone mafia family in New York. He is at...
От Leonard Pokrovski 2022-10-31 19:32:39 0 29Кб

BigMoney.VIP Powered by Hosting Pokrov