Encoding and Decoding Base64 Strings in Python

0
10KB

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
Child Health
Understanding Child Health: Foundations for a Lifetime of Wellness
Child health is one of the most important aspects of overall well-being. Early childhood is a...
Por Dacey Rankins 2024-11-28 15:00:23 0 6KB
Accounting
Collection of jokes about accountants and programmers
Collection of jokes about accountants and programmers Start the morning with a humorous...
Por Leonard Pokrovski 2024-03-11 21:36:46 0 25KB
Mental Health
Autism Diagnosis: Gradual autism development
Most parents report that the onset of autism features appear within the first or second year of...
Por Kelsey Rodriguez 2023-03-21 15:58:15 0 9KB
Mental Health
Psychosis: Psychoactive Drugs
Various psychoactive substances (both legal and illegal) have been implicated in causing,...
Por Kelsey Rodriguez 2023-05-29 18:19:02 0 9KB
Social Issues
Mr. Smith Goes to Washington. (1939)
A naive youth leader is appointed to fill a vacancy in the U.S. Senate. His idealistic plans...
Por Leonard Pokrovski 2023-04-05 14:54:34 0 23KB
image/svg+xml


BigMoney.VIP Powered by Hosting Pokrov