Encoding and Decoding Base64 Strings in Python

0
14Кб

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)
Поиск
Категории
Больше
Mental Health
ADHD: Exercise
Regular physical exercise, particularly aerobic exercise, is an effective add-on treatment for...
От Kelsey Rodriguez 2023-05-03 17:41:29 0 11Кб
Телевидение
Прямой эфир ТВ-3
ТВ3 – особый телеканал, делающий особый акцент на присутствие в своём эфире фильмов и...
От Nikolai Pokryshkin 2022-09-30 10:49:05 0 36Кб
Financial Services
Ways to save money on your monthly bills
Finding ways to save money may be easier than you think. By setting aside just a few...
От Mark Lorenzo 2023-05-19 20:00:06 0 13Кб
Business
How Do Startup Founders Find Co-Founders?
Starting a new venture can be an exciting yet challenging journey. For many startup founders, one...
От Dacey Rankins 2025-04-02 16:38:36 0 11Кб
Europe
Europe: A Tapestry of Culture, History, and Diversity
Europe: A Tapestry of Culture, History, and Diversity Europe, the cradle of Western...
От Leonard Pokrovski 2024-05-22 19:57:18 0 20Кб

BigMoney.VIP Powered by Hosting Pokrov