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
Personal Finance
How Do I Handle Irregular Expenses?
How Do I Handle Irregular Expenses? Managing money can be challenging even when your expenses...
Por Leonard Pokrovski 2025-10-21 20:20:08 0 6K
Искусство, культура и развлечения
Фестиваль Рифкина. Rifkin's Festival. (2020)
В самом красивом городе на берегу Испании царит романтическое настроение и проходит престижный...
Por Nikolai Pokryshkin 2022-09-28 19:32:11 0 30K
Business
What Are Some Examples of Feedback Questions?
Sample Questions to Solicit Feedback Effectively Feedback is a vital resource for improving...
Por Dacey Rankins 2025-05-28 14:22:10 0 9K
Business
What is Company Culture?
Company culture encompasses the shared values, beliefs, attitudes, actions, and practices that...
Por Dacey Rankins 2025-06-10 15:22:52 0 6K
Sport
Warrior. (2011)
The youngest son of an alcoholic former boxer returns home, where he's trained by his father for...
Por Leonard Pokrovski 2023-03-12 17:31:43 0 25K

BigMoney.VIP Powered by Hosting Pokrov