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)
Поиск
Категории
Больше
Business
How Do I Develop a Business Strategy?
Developing a business strategy is essential for guiding an organization toward its long-term...
От Dacey Rankins 2024-12-24 13:06:37 0 23Кб
Business
How Do I End a Presentation?
Ending a presentation is just as important as starting one — and in many cases, even more...
От Dacey Rankins 2025-12-04 16:23:11 0 3Кб
Social Issues
The Great Dictator. (1940)
Dictator Adenoid Hynkel tries to expand his empire while a poor Jewish barber tries to avoid...
От Leonard Pokrovski 2022-12-21 19:24:05 0 22Кб
Programming
Python Tips
Getting a "f-string expression part cannot include a backslash" Synatx error? You can create a...
От Jesse Thomas 2023-02-14 21:54:58 0 11Кб
Science Fiction and Fantasy
Mad Max: Fury Road. (2015)
In a post-apocalyptic wasteland, a woman rebels against a tyrannical ruler in search for her...
От Leonard Pokrovski 2023-04-06 19:58:58 0 32Кб

BigMoney.VIP Powered by Hosting Pokrov