Encoding and Decoding Base64 Strings in Python

0
14K

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
Mental Health
ADHD: In adults
Adults with ADHD are diagnosed under the same criteria, including that their signs must have been...
Por Kelsey Rodriguez 2023-04-24 16:51:27 0 11K
Business
What Do You Like Most About Working for This Company?
During a job interview, one insightful question candidates often ask is: "What do you like most...
Por Dacey Rankins 2025-06-24 15:32:48 0 6K
Научная фантастика и фэнтези
Мстители: Война бесконечности. Avengers: Infinity War. (2018)
Пока Мстители и их союзники продолжают защищать мир от различных опасностей, с которыми не смог...
Por Nikolai Pokryshkin 2022-12-17 20:45:04 0 49K
Advice
Secrets of Productivity
Is this productivity needed at all?Productive – creating value, bringing results. The...
Por FWhoop Xelqua 2023-06-05 19:00:41 0 20K
Life Issues
Joker. (2019)
A mentally troubled stand-up comedian embarks on a downward spiral that leads to the creation of...
Por Leonard Pokrovski 2022-12-31 20:16:41 0 21K

BigMoney.VIP Powered by Hosting Pokrov