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
Real Estate
Real Estate: A Cornerstone of the Economy
Real estate is one of the most significant sectors in the global economy, influencing not only...
Por Dacey Rankins 2025-01-22 14:32:32 0 9K
Arts, Culture and Entertainment
Annette. (2021)
Los Angeles, nowadays. Henry is a stand-up comedian with a fierce humor. Ann, an internationally...
Por Nikolai Pokryshkin 2022-09-01 20:11:00 1 37K
Business
Can a Startup Biography Evolve Over Time?
A startup biography isn’t a one-and-done document. Just like the company it represents, a...
Por Dacey Rankins 2025-04-19 14:49:54 0 7K
Regional
Global Innovation Index 2022
According toWIPO's 2022 Global Innovation Index (GII) report, the world's most innovative...
Por FWhoop Xelqua 2022-11-23 14:23:39 0 24K
История
Нюрнбергский процесс. Judgment at Nuremberg. (1961)
В Нюрнберге идет процесс над нацистскими преступниками. Слушаются дела юристов, служивших...
Por Nikolai Pokryshkin 2023-02-09 12:22:42 0 21K
image/svg+xml


BigMoney.VIP Powered by Hosting Pokrov