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)
Pesquisar
Categorias
Leia Mais
Stories
Once Upon a Time in the West (1968)
A mysterious stranger with a harmonica joins forces with a notorious desperado to protect a...
Por Leonard Pokrovski 2022-12-08 19:28:57 0 24K
Business
How Do I Start My Own Business? A Step-by-Step Guide
Starting your own business can be one of the most rewarding decisions of your life. It offers the...
Por Dacey Rankins 2025-03-12 14:46:33 0 9K
Financial Services
Command-and-control regulation
Key points Command-and-control regulation sets specific limits for pollution...
Por Mark Lorenzo 2023-05-01 20:28:31 0 14K
Life Issues
Memento. (2000)
A man with short-term memory loss attempts to track down his wife's murderer. My Link
Por Leonard Pokrovski 2022-12-13 21:06:02 0 25K
Телевидение
6ТВ прямая трансляция, г. Горловка.
Телеканал «6ТВ» г. Горловка - первооткрыватель ТВ-пространства в Горловке. За годы...
Por Nikolai Pokryshkin 2022-11-14 19:10:38 0 39K

BigMoney.VIP Powered by Hosting Pokrov