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)
Поиск
Категории
Больше
Healthcare
Understanding Healthcare: A Comprehensive Overview
Healthcare is a vital component of society, encompassing a broad range of services aimed at...
От Dacey Rankins 2024-10-15 17:58:39 0 19Кб
Personal Development
How can I improve self-discipline?
How Can I Improve Self-Discipline? Self-discipline is the ability to control your impulses,...
От Michael Pokrovski 2026-02-09 23:41:16 0 21Кб
Social Issues
Girl in the Basement. (2021)
Sarah is a teen girl who is looking forward to her 18th birthday to move away from her...
От Leonard Pokrovski 2023-04-28 19:44:31 0 37Кб
Life Issues
The Notebook. (2004)
A poor yet passionate young man falls in love with a rich young woman, giving her a sense of...
От Leonard Pokrovski 2023-05-07 20:10:43 0 37Кб
Electronics and Electrical
Smart Base for TV
  Smart Base for TV – this device, eliminates the flaw that all TVs have: it...
От Smart Base for TV 2024-11-12 11:41:07 0 15Кб

BigMoney.VIP Powered by Hosting Pokrov