Encoding and Decoding Base64 Strings in Python

0
14KB

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
Спорт
Бойцовский клуб. Fight Club. (1999)
Сотрудник страховой компании страдает хронической бессонницей и отчаянно пытается вырваться из...
Por Nikolai Pokryshkin 2022-11-07 20:17:51 0 45KB
Programming
Tailwind CSS Vs Bootstrap
CSS (Cascading Style Sheets) is a stylesheet language used to style the HTML elements in a...
Por Jesse Thomas 2023-06-14 19:56:18 0 12KB
История
Бункер. Downfall. (2004)
Апрель 1945 года. Советские войска сжимают кольцо вокруг столицы Третьего рейха – Берлина....
Por Nikolai Pokryshkin 2023-02-01 23:26:15 0 34KB
Business
Key Challenges and Outcomes: What’s Most Difficult and Impactful?
Mentoring and coaching relationships can be transformative—but they’re not without...
Por Dacey Rankins 2025-07-23 12:11:47 0 4KB
Programming
Python Force Raise Errors
You can force raise errors for your application in your library/code. These errors can be useful...
Por Jesse Thomas 2023-02-20 22:00:40 0 12KB

BigMoney.VIP Powered by Hosting Pokrov