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)
Site içinde arama yapın
Kategoriler
Read More
Научная фантастика и фэнтези
Властелин колец: Возвращение короля. The Lord of the Rings: The Return of the King. (2003)
Повелитель сил тьмы Саурон направляет свою бесчисленную армию под стены Минас-Тирита, крепости...
By Nikolai Pokryshkin 2022-11-03 20:37:27 0 39K
История
Иди и смотри. (1985)
1943 год, Великая Отечественная война. Подросток Флёра, откопав карабин среди обрывков колючей...
By Nikolai Pokryshkin 2023-01-12 19:19:09 0 27K
Card Games
Collectible Card Game
Collectible Card Game A Collectible Card Game (CCG) is a type...
By Leonard Pokrovski 2024-04-10 00:52:26 0 12K
Biography
How to write an autobiography
An autobiography is a short story about yourself, which allows you to find out general...
By FWhoop Xelqua 2022-10-22 12:07:43 0 24K
Sepak Takraw
Sepak Takraw: The Elegant Fusion of Skill and Athleticism
Sepak Takraw: The Elegant Fusion of Skill and Athleticism Sepak Takraw, often referred to as...
By Leonard Pokrovski 2024-07-08 02:02:03 0 22K

BigMoney.VIP Powered by Hosting Pokrov