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)
Search
Categories
Read More
Business
When Is Mentoring or Coaching Appropriate? Knowing the Right Time for Each
Professional development isn’t one-size-fits-all. Depending on your goals, you may benefit...
By Dacey Rankins 2025-07-08 13:49:26 0 2K
Телевидение
Телеканал Вкусное TV
Вкусное ТВ - тематический канал, ориентированный на тех, кто интересуется кулинарией и любит...
By Nikolai Pokryshkin 2022-11-02 18:40:40 0 28K
Online
Most Popular eSports Games
Esports Charts compiled the top most viewed disciplines in 2022 and compared their audience...
By FWhoop Xelqua 2023-02-20 11:49:06 0 18K
Искусство, культура и развлечения
Мадам Парфюмер. Perfumes. (2020)
Анна Вальберг — знаменитость в мире парфюмерии. Она живет как дива, ведет себя как эгоистка...
By Nikolai Pokryshkin 2022-09-30 21:26:20 0 22K
Television
The Evolution of Television: From the Box to the Digital Revolution
Television has been one of the most influential inventions of the 20th century, shaping...
By Dacey Rankins 2024-11-14 16:08:01 0 10K

BigMoney.VIP Powered by Hosting Pokrov