Skip to content

Encoding

Robert edited this page Aug 27, 2023 · 1 revision

Encoding

Base64

from theeverythinglibrary.encoding import TELEncoding

encoding = TELEncoding()

encoded_text = encoding.base64_encode(plaintext="Hello World!", encoding='utf-8') # The encoding can be in many formats (hex, ascii, etc.)

print(encoded_text)
>>> SGVsbG8gV29ybGQh

decoded_text = encoding.base64_decode(encoded_text=encoded_text, encoding='utf-8') # The encoding can be in many formats (hex, ascii, etc.)

print(decoded_text)
>>> Hello World!

Hex

from theeverythinglibrary.encoding import TELEncoding

encoding = TELEncoding()

encoded_text = encoding.hex_encode(plaintext="Hello World!")

print(encoded_text)
>>> 48656c6c6f20576f726c6421

decoded_text = encoding.hex_decode(encoded_text=encoded_text)

print(decoded_text)
>>> Hello World!

Binary

from theeverythinglibrary.encoding import TELEncoding

encoding = TELEncoding()

encoded_text = encoding.binary_encode(plaintext="Hello World!", as_bytes=False) # As bytes should be false most times

print(encoded_text)
>>> 01001000 01100101 01101100 01101100 01101111 00100000 01010111 01101111 01110010 01101100 01100100 00100001

decoded_text = encoding.binary_decode(encoded_text=encoded_text)

print(decoded_text)
>>> Hello World!

Clone this wiki locally