Encoding and Decoding Base64 Strings in Python

0
13K

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)
Căutare
Categorii
Citeste mai mult
Social Issues
Citizenfour (2014)
A documentarian and a reporter travel to Hong Kong for the first of many meetings with Edward...
By Leonard Pokrovski 2023-07-22 17:12:43 0 26K
Business
How Do I Speak Confidently During a Presentation?
Confidence during a presentation isn’t something you’re born with — it’s...
By Dacey Rankins 2025-12-05 18:32:46 0 983
История
Однажды на Диком Западе. Once Upon a Time in the West (1968)
Молодая вдова отказывается продать ферму дельцу, задумавшему проложить по этой земле железную...
By Nikolai Pokryshkin 2022-12-07 19:10:08 0 28K
Business
Can a business biography help in networking?
In today’s interconnected world, networking is a key aspect of building a successful career...
By Dacey Rankins 2025-01-07 14:18:30 0 17K
Drugs
Exploring the Recreational Use of Prescription Drugs: Balancing Benefits and Risks
Exploring the Recreational Use of Prescription Drugs: Balancing Benefits and Risks Introduction:...
By Leonard Pokrovski 2024-05-09 10:00:34 0 19K

BigMoney.VIP Powered by Hosting Pokrov