-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.py
31 lines (29 loc) · 815 Bytes
/
main.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
import base64
def textToNumber(text):
ansii = [ord(c) for c in text]
print(f"Ansii: {ansii}")
text_bytecode = text.encode("utf-8")
hex = text_bytecode.hex()
print(f"Hex: {hex}")
baseSixFour = base64.b64encode(text_bytecode)
print(f"base64: {baseSixFour}")
def numberToText(standart, data):
if standart == "base-10":
try:
dec16 = hex(data)
text = bytes.fromhex(dec16[2:])
print(f"Message: {text}")
except TypeError:
print("Wrong data type")
if standart == "hex":
try:
text = bytes.fromhex(data[2:])
print(f"Message: {text}")
except TypeError:
print("Wrong data type")
if standart.lower() == "ansii":
try:
text = ''.join(chr(c) for c in data)
print(f"Message: {text}")
except TypeError:
print("Wrong data type")