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
Stories
Zeitgeist (2007)
Mythology and belief in society today, presenting uncommon perspectives of common cultural...
Por Leonard Pokrovski 2023-07-15 20:09:29 0 29K
Business
How do I attract investors for my business?
Securing investors is a crucial step for many entrepreneurs looking to grow their businesses....
Por Dacey Rankins 2025-03-13 16:39:00 0 14K
Life Issues
The Kid. (1921)
The Tramp cares for an abandoned child, but events put their relationship in jeopardy. My Link
Por Leonard Pokrovski 2023-02-04 17:51:54 0 19K
Социальные проблемы
Мулан. Mulan. (2020)
Изданный императором Китая указ о призыве на службу в армии одного мужчины из каждой семьи для...
Por Nikolai Pokryshkin 2022-10-14 20:15:04 0 28K
Middle East
Top 10 attractions in the Middle East
But did you know that the Middle East is made up of 14 different...
Por FWhoop Xelqua 2023-03-08 14:45:39 0 19K

BigMoney.VIP Powered by Hosting Pokrov