Encoding and Decoding Base64 Strings in Python

0
6KB

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
Programming
Python Microsoft Store API
The following example demonstrates how to obtain an Azure AD access token that you can...
Por Jesse Thomas 2023-04-25 21:48:29 0 5KB
Programming
Use Aiohttp For Requests
People have been using requests to get, post, and other methods for requests. Although there is...
Por Jesse Thomas 2023-02-08 22:43:17 0 5KB
Home Health
How pet dogs and cats improve human physical and mental health
How pet dogs and cats improve human physical and mental health Pets bring joy, love...
Por Leonard Pokrovski 2024-04-16 19:43:43 0 9KB
Programming
OpenAI ChatGPT Python Compiler
ChatGPT can help you in many issues that you occur. Since AI is here, it can do almost anything...
Por Jesse Thomas 2023-04-17 19:50:45 0 5KB
История
Бункер. Downfall. (2004)
Апрель 1945 года. Советские войска сжимают кольцо вокруг столицы Третьего рейха – Берлина....
Por Nikolai Pokryshkin 2023-02-01 23:26:15 0 17KB
image/svg+xml


BigMoney.VIP Powered by Hosting Pokrov