Python Base

Base.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 base64codes():
s = input()
b64encode = base64.b64encode(s.encode(encoding='utf-8'))
b32encode = base64.b32encode(s.encode(encoding='utf-8'))
b16encode = base64.b16encode(s.encode(encoding='utf-8'))
print(b64encode.decode(encoding='utf-8'))
print(b32encode.decode(encoding='utf-8'))
print(b16encode.decode(encoding='utf-8'))
print('---------------------------------')
try:
b64decode = base64.b64decode(s.encode(encoding='utf-8'))
print(b64decode.decode(encoding='utf-8'))
except Exception as e:
print("",end="")
try:
b32decode = base64.b32decode(s.encode(encoding='utf-8'))
print(b32decode.decode(encoding='utf-8'))
except Exception as e:
print("",end="")
try:
b16decode = base64.b16decode(s.encode(encoding='utf-8'))
print(b16decode.decode(encoding='utf-8'))
except Exception as e:
print("",end="")
if __name__ == '__main__':
try:
while True:
base64codes()
except EOFError:
exit()

评论