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)
Pesquisar
Categorias
Leia Mais
Business
What Are the Key Responsibilities of a Startup CEO?
  The role of a startup CEO is both exhilarating and daunting. Unlike in mature companies...
Por Dacey Rankins 2025-05-01 16:21:54 0 8K
История
Телохранитель. Yojimbo. (1961)
В некий японский городок приходит самурай. Самурай выглядит совершенно не по-самурайски: плохо...
Por Nikolai Pokryshkin 2023-02-19 14:43:31 0 23K
Marketing and Advertising
How to Analyze and Interpret Market Research Data (Turning Insights into Action)
Introduction Collecting market research data is only half the battle — the real value lies...
Por Dacey Rankins 2025-10-13 17:51:54 0 2K
Life Issues
It's a Wonderful Life. (1946)
An angel is sent from Heaven to help a desperately frustrated businessman by showing him what...
Por Leonard Pokrovski 2022-11-16 21:02:59 0 24K
Segurança
Understanding Computer Security: Safeguarding the Digital Age
In today’s interconnected world, where nearly every aspect of our lives is touched by...
Por Dacey Rankins 2024-11-15 14:56:17 0 13K

BigMoney.VIP Powered by Hosting Pokrov