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
Business
What Are the Key Stages or Process of Innovation?
Innovation is the engine of business growth. It transforms ideas into marketable products and...
Por Dacey Rankins 2025-08-19 17:50:58 0 3K
Literature
The Power of Literature: Exploring the Depths of Human Experience
Literature is one of humanity's most cherished and enduring forms of expression. It encompasses...
Por Dacey Rankins 2024-12-13 14:28:38 0 10K
Научная фантастика и фэнтези
Бегущий по лезвию. Blade Runner. (1982)
Ноябрь 2019 года. Бывший охотник на андроидов Рик Декард восстановлен в полиции Лос-Анджелеса для...
Por Nikolai Pokryshkin 2023-03-17 14:58:57 0 33K
Business
What is a Lean Business Plan?
In the world of business planning, traditional, lengthy documents are being replaced by more...
Por Dacey Rankins 2024-12-19 15:09:19 0 14K
Finance
What Time Frame Should I Use in Forex?
What Time Frame Should I Use in Forex? Trading in the foreign exchange (Forex) market involves...
Por Leonard Pokrovski 2025-10-15 11:14:16 0 2K

BigMoney.VIP Powered by Hosting Pokrov