Encoding and Decoding Base64 Strings in Python

0
10K

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)
Pesquisar
Categorias
Leia Mais
Science Fiction and Fantasy
Aquaman. (2018)
Arthur Curry, the human-born heir to the underwater kingdom of Atlantis, goes on a quest to...
Por Leonard Pokrovski 2023-05-01 20:24:58 0 24K
Programming
Proxy Webserver in Python
Socket programming in python is very user friendly as compared to c. The programmer need not...
Por Jesse Thomas 2023-03-13 22:09:22 0 8K
Hacking
Hacking as a business. Is it possible to make money from this?
Hello, dear friends. Hacking, the illegal use of computer technology to gain unauthorized access...
Por Michael Pokrovski 2024-03-25 20:41:23 0 20K
Социальные проблемы
Заводной апельсин. A Clockwork Orange. (1971)
Безжалостный лидер банды подростков, совершающей убийства и изнасилования, попадает в тюрьму и...
Por Nikolai Pokryshkin 2023-01-19 18:54:12 0 25K
Business
What Role Does Company Culture Play in Team Motivation?
Company culture is more than just a buzzword—it’s the foundation that shapes how...
Por Dacey Rankins 2025-05-20 14:47:29 0 3K
image/svg+xml


BigMoney.VIP Powered by Hosting Pokrov