Encoding and Decoding Base64 Strings in Python

0
11K

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)
Buscar
Categorías
Read More
Business
Why Do I Want to Start a Business?
Starting a business is a big decision—one that involves time, effort, and often a...
By Dacey Rankins 2025-02-05 15:53:48 0 8K
Business
Examples of guerrilla marketing – promotion through creativity in advertising with a small budget
Many have heard of the term guerrilla marketing, but few have really resorted to it, and it is an...
By Dacey Rankins 2024-09-04 15:56:15 0 12K
Jai Alai
ChatGPT Jai Alai: The Thrilling Basque Sport Making Waves
In the world of sports, where fast-paced action meets precise skill, few games can match the...
By Dacey Rankins 2024-06-28 22:27:37 0 18K
Природа и наука
Кролик Питер 2. Peter Rabbit 2: The Runaway. (2021)
Продолжение истории маленького и непоседливого кролика по имени Питер. Беатрис, Томас и...
By Nikolai Pokryshkin 2022-09-17 19:02:02 0 24K
Hardware
Understanding Computer Hardware: The Backbone of Every Device
In the world of technology, hardware is the essential physical component that powers every...
By Dacey Rankins 2025-01-24 18:07:02 0 9K

BigMoney.VIP Powered by Hosting Pokrov