Encoding and Decoding Base64 Strings in Python

0
9K

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)
Cerca
Categorie
Leggi tutto
Financial Services
The benefits and costs of US environmental laws
Key points Taken as a whole, the benefits of US environmental regulation have...
By Mark Lorenzo 2023-02-20 17:47:53 0 8K
Developers and Publishers
Video Game Publisher
A computer game publisher is a company that publishes computer games developed internally or by...
By Dacey Rankins 2024-04-02 17:21:22 0 10K
Социальные проблемы
Фарго. Fargo. (1996)
Для робкого менеджера по продажам, работающего у собственного тестя, похищение собственной жены...
By Nikolai Pokryshkin 2023-03-12 15:15:44 0 19K
Научная фантастика и фэнтези
Как приручить дракона. How to Train Your Dragon. (2010)
Вы узнаете историю подростка Иккинга, которому не слишком близки традиции его героического...
By Nikolai Pokryshkin 2023-04-07 13:57:17 0 25K
Television
Fox 61 CT Live TV. Hartford, Connecticut, USA
Fox CT (WTIC) is a Fox affilitate local TV channel from Hartford, Connecticut. The channel first...
By Nikolai Pokryshkin 2022-10-23 11:18:41 0 25K
image/svg+xml


BigMoney.VIP Powered by Hosting Pokrov