Encoding and Decoding Base64 Strings in Python

0
14KB

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
Business
CLUSTER APPROACH IN ECONOMICS: THEORETICAL FOUNDATIONS AND PRACTICE OF APPLICATION
CLUSTER APPROACH IN ECONOMICS: THEORETICAL FOUNDATIONS AND PRACTICE OF APPLICATION Even though...
Por Leonard Pokrovski 2024-08-03 21:45:09 0 25KB
Urban Living
Such a funny city life: 15 shots by street photographers from around the world
Such a funny city life: 15 shots by street photographers from around the world Hello Friends...
Por Leonard Pokrovski 2024-04-26 21:34:21 0 16KB
Biology
Scarlet Macaw
Scarlet Macaw (Ara Macao) – With a spectacular plumage and an inquisitive nature these...
Por FWhoop Xelqua 2023-05-15 20:37:55 0 24KB
Business
How Can I Find a Suitable Mentor?
Finding the right mentor can be a transformative step in your personal and professional journey....
Por Dacey Rankins 2025-05-24 15:40:45 0 8KB
Marketing and Advertising
What Agencies Were Founded by Famous Advertisers?
Some of the world’s most influential advertising agencies did not begin as large corporate...
Por Dacey Rankins 2026-01-08 11:56:18 0 1KB

BigMoney.VIP Powered by Hosting Pokrov