Encoding and Decoding Base64 Strings in Python

0
6KB

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
Nach Verein filtern
Read More
Science Fiction and Fantasy
Back to the Future. (1985)
Marty McFly, a 17-year-old high school student, is accidentally sent 30 years into the past in a...
Von Leonard Pokrovski 2022-11-24 18:54:33 0 18KB
Social Issues
Miss Marx (2020)
Bright, intelligent, passionate and free, Eleanor is Karl Marx's youngest daughter. Among the...
Von Leonard Pokrovski 2022-10-13 18:27:01 0 14KB
Roads and Highways
Navigating the World's Arteries: A Comprehensive Look at Roads and Highways
Roads and highways are the lifelines of modern civilization, weaving through landscapes,...
Von Dacey Rankins 2024-05-15 18:29:36 0 7KB
Television
Fairfax Ch. 16. Live TV. Virginia, USA.
Stay informed! Watch Fairfax County public meetings live, and the latest events and activities on...
Von Nikolai Pokryshkin 2022-10-14 17:17:39 0 18KB
Business
Flower business at home
Flower business at home Opening a flower business at home can be a great idea...
Von Leonard Pokrovski 2024-07-22 21:02:09 0 8KB
image/svg+xml


BigMoney.VIP Powered by Hosting Pokrov