Encoding and Decoding Base64 Strings in Python

0
15Кб

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)
Поиск
Категории
Больше
Социальные проблемы
Свидетель обвинения. Witness for the Prosecution. (1957)
Сэр Уилфрид Робартс - тяжело больной адвокат, которому врачи запретили заниматься уголовными...
От Nikolai Pokryshkin 2022-12-19 12:01:57 0 26Кб
Decision Making and Problem Solving
How can I think more logically?
You sit down to analyze a high-stakes argument or a complex professional dilemma, armed with...
От Michael Pokrovski 2026-07-22 15:06:46 0 636
Economics
What is elasticity in economics?
Elasticity in Economics: The Quiet Geometry of Human Response There is something deceptively...
От Leonard Pokrovski 2026-04-29 20:37:35 0 4Кб
Economics
What is monetary policy?
What Is Monetary Policy? Monetary policy is the process by which a country's central bank...
От Leonard Pokrovski 2026-07-24 02:21:38 0 2Кб
Programming
Python Fun Fact
There's a fact about Python that you might not know! Python has a module called "this". The...
От Jesse Thomas 2023-02-03 19:15:26 0 15Кб

BigMoney.VIP Powered by Hosting Pokrov