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
Home and Garden
Cultivating Comfort: Navigating the World of Home and Garden Shopping
Cultivating Comfort: Navigating the World of Home and Garden Shopping In the realm of home and...
Por Leonard Pokrovski 2024-06-01 12:04:31 0 34K
Телевидение
Телеканал Вкусное TV
Вкусное ТВ - тематический канал, ориентированный на тех, кто интересуется кулинарией и любит...
Por Nikolai Pokryshkin 2022-11-02 18:40:40 0 31K
Social Issues
It Happened One Night (1934)
A renegade reporter trailing a young runaway heiress for a big story joins her on a bus heading...
Por Leonard Pokrovski 2023-06-28 19:38:38 0 26K
Television
Eternal Word Television Network (EWTN). Live TV.
Catholic Television by providing quality programming faithful to the teachings of the Catholic...
Por Nikolai Pokryshkin 2022-09-29 19:55:16 0 43K
Finance
How to budget properly
Saving money can be a straightforward process if you approach it with some planning and...
Por Dacey Rankins 2024-10-04 15:54:02 0 11K

BigMoney.VIP Powered by Hosting Pokrov