- import base64
- str='admin'
- str=str.encode('utf-8')
- #加密
- bs64=base64.b64encode(str)
- #解密
- debs64=base64.b64decode(bs64)
- print(debs64.decode("utf-8"))
- #base32bit加密
- bs32=base64.b32encode(str)
- #b32解密
- debs32=base64.b32decode(bs32)
- print(debs32.decode("utf-8"))关于md5 以及sha1:
import hashlib
print("在所有平台上,保证被hashlib模块支持的hash算法名称的集合:\n{}".format( hashlib.algorithms_guaranteed))
m=hashlib.md5("张三".encode("utf-8")).hexdigest()
print(m)
k1=b"byte111"
k2=b"byte222"
arg=hashlib.md5()
n=arg.update(k1+k2) # 等价于2步arg.update(k1) arg.update(k2)
print(arg.hexdigest())
sha=hashlib.sha1("zhan".encode("utf-8")).hexdigest()
print(sha)
""" 在所有平台上,保证被hashlib模块支持的hash算法名称的集合:
{'md5', 'sha512', 'blake2b', 'sha3_512', 'sha3_384', 'shake_256', 'sha256', 'sha3_256', 'sha384', 'sha3_224', 'sha1', 'blake2s', 'sha224', 'shake_128'}
615db57aa314529aaa0fbe95b3e95bd3
c2dcabc61522e768ed500222191ea7e5
9ac5dda30864f23386d2b66c6d6aa40357c1d9bd
"""