Encoding and Decoding Base64 Strings in Python

0
7K

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)
Site içinde arama yapın
Kategoriler
Read More
Life Issues
Me Before You. (2016)
A girl in a small town forms an unlikely bond with a recently-paralyzed man she's taking care of....
By Leonard Pokrovski 2023-05-20 14:43:09 0 29K
Телевидение
«Охотник и рыболов» - ТВ прямой эфир.
«Охотник и рыболов» - отличный выбор для тех, кому нравится природа, и просто для...
By Nikolai Pokryshkin 2022-10-27 12:03:57 0 25K
Financial Services
Interpreting the aggregate demand/aggregate supply model
Key points The aggregate demand/aggregate supply model is a model that...
By Mark Lorenzo 2023-03-08 17:45:51 0 10K
EĞİTİM BİLGİLERİ
The Importance of Art Education: Cultivating Creativity and Critical Thinking
Art education is a vital component of a well-rounded academic curriculum. While subjects like...
By Dacey Rankins 2025-01-20 16:19:05 0 3K
Science Fiction and Fantasy
Star Wars: Episode IV - A New Hope. (1977)
Luke Skywalker joins forces with a Jedi Knight, a cocky pilot, a Wookiee and two droids to save...
By Leonard Pokrovski 2022-11-22 10:13:34 0 19K
image/svg+xml


BigMoney.VIP Powered by Hosting Pokrov