Encoding and Decoding Base64 Strings in Python

0
15Кб

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)
Поиск
Категории
Больше
Nature and Science
The Current War. (2018)
The dramatic story of the cutthroat race between electricity titans Thomas A. Edison and George...
От Leonard Pokrovski 2023-05-29 19:44:35 0 33Кб
Marketing and Advertising
How Does a CMO Align Marketing with Business Objectives?
In today’s competitive business environment, a Chief Marketing Officer (CMO) cannot operate...
От Dacey Rankins 2025-09-25 15:42:11 0 13Кб
Economics
How does Brexit affect EU citizens living in the UK?
Introduction: What Changed After Brexit? Before Brexit, EU citizens enjoyed freedom of movement...
От Leonard Pokrovski 2026-02-04 00:19:18 0 4Кб
Personal Finance
What If My Income Fluctuates?
What If My Income Fluctuates? How to Budget Smartly When Your Earnings Vary Each Month Managing...
От Leonard Pokrovski 2025-10-21 20:16:40 0 6Кб
Телевидение
Антимайдан. Соловьев Live TV. Круглосуточный прямой эфир.
Авторская политическая программа журналиста, радио- и телеведущего Владимира Соловьева.В прямом...
От Nikolai Pokryshkin 2023-03-06 16:48:08 0 32Кб

BigMoney.VIP Powered by Hosting Pokrov