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)
Поиск
Категории
Больше
Science Fiction and Fantasy
Star Wars: Episode V - The Empire Strikes Back. (1980)
After the Rebels are brutally overpowered by the Empire on the ice planet Hoth, Luke Skywalker...
От Leonard Pokrovski 2022-11-13 20:22:35 0 25Кб
Marketing and Advertising
Guerrilla Marketing vs. Viral and Traditional Marketing: What’s the Difference?
Understanding what sets guerrilla tactics apart from viral content and conventional advertising....
От Dacey Rankins 2025-10-07 17:33:24 0 7Кб
Programming
Python Web Scraping
Sometimes, you may come across a site that doesn't have an API and you want to get data from the...
От Jesse Thomas 2023-02-06 21:58:59 0 12Кб
Business
What is business forecasting?
Business forecasting is the practice of using tools and techniques to predict future developments...
От Dacey Rankins 2025-01-09 15:38:09 0 11Кб
Business
How Long Does a Business Consulting Project Usually Take?
Business consulting is a key element in helping organizations improve performance, solve...
От Dacey Rankins 2025-02-11 15:35:22 0 15Кб

BigMoney.VIP Powered by Hosting Pokrov