Encoding and Decoding Base64 Strings in Python

0
12K

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)
Site içinde arama yapın
Kategoriler
Read More
Business
What is the difference between financial forecasting and budgeting?
In the world of business finance, financial forecasting and budgeting are two essential tools...
By Dacey Rankins 2025-01-10 14:19:37 0 9K
Жизненные вопросы
Перед рассветом. Before Sunrise. (1995)
Молодой американец Джесси знакомится в поезде с красивой француженкой Селин. Они сразу находят...
By Nikolai Pokryshkin 2023-03-19 14:14:00 0 28K
Искусство, культура и развлечения
Аннетт. Annette. (2021)
Действие развернётся в Лос-Анджелесе. По сюжету Генри работает стендап-комиком, а его супруга Энн...
By Nikolai Pokryshkin 2022-09-03 21:19:35 0 44K
История
Однажды на Диком Западе. Once Upon a Time in the West (1968)
Молодая вдова отказывается продать ферму дельцу, задумавшему проложить по этой земле железную...
By Nikolai Pokryshkin 2022-12-07 19:10:08 0 26K
Social Issues
The Sting. (1973)
Two grifters team up to pull off the ultimate con. My Link
By Leonard Pokrovski 2023-01-25 13:30:10 0 19K

BigMoney.VIP Powered by Hosting Pokrov