Encoding and Decoding Base64 Strings in Python

0
13K

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)
Căutare
Categorii
Citeste mai mult
Business
Digital marketing
Digital marketing is a way to promote goods and services over the Internet. To find new...
By Dacey Rankins 2024-09-03 18:43:08 0 14K
Business
From Influencer Marketing to Sales: How to Turn Popularity into Profit
In 2024, this direction is undergoing a transformation, becoming a key factor in the sales...
By Dacey Rankins 2024-09-04 16:16:10 0 14K
Dice
The Fascinating World of Dice Games: A Blend of Chance and Strategy
Dice are among the oldest and most universal gaming tools, used in countless games across...
By Dacey Rankins 2024-12-02 14:52:55 0 9K
Жизненные вопросы
1+1. The Intouchables. (2011)
Пострадав в результате несчастного случая, богатый аристократ Филипп нанимает в помощники...
By Nikolai Pokryshkin 2022-12-05 20:58:24 0 44K
Bodyart
Body Art
Body art is a form of avant-garde art that developed in the 1960s. The main object of body art is...
By FWhoop Xelqua 2023-06-26 17:01:47 0 23K

BigMoney.VIP Powered by Hosting Pokrov