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
Социальные проблемы
Судная ночь навсегда. The Forever Purge. (2021)
Этим летом все правила будут нарушены. Группа мародеров решает, что ежегодная Судная ночь не...
Por Nikolai Pokryshkin 2022-09-11 20:10:36 1 27K
Skating
The Art and Thrill of Sports Skating
Skating, a timeless blend of grace and adrenaline, has captivated enthusiasts and athletes alike...
Por Dacey Rankins 2024-07-09 16:23:25 0 20K
Productivity
How much time should I spend on each task?
How Much Time Should I Spend on Each Task? One of the most common productivity questions is: How...
Por Michael Pokrovski 2026-03-05 17:36:44 0 3K
Programming
Make A 2D Game With Unity
How to Create a 2D Game in Unity To create 2D games, we need to use Unity Hub. Unity...
Por Jesse Thomas 2023-06-28 21:18:55 0 13K
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 21K

BigMoney.VIP Powered by Hosting Pokrov