宽容他人,放过自己。

python加密解密

Posted on By anchoriteFili

import hashlib

# md5加密
m2 = hashlib.md5()
m2.update('特雷弗·沃尔')
print m2.hexdigest()

# sha1加密
sha1obj = hashlib.sha1()
sha1obj.update('特雷弗·沃尔')
hash = sha1obj.hexdigest()
print(hash)
print

import base64

# base64加密解密
s = '特雷弗·沃尔'
a = base64.b64encode(s)
print a

print base64.b64decode(a)
print base64.b64decode('MTAzMTgx')
print base64.b64decode('d2Vib3Nz')
print base64.b64decode('17a4eb8adc5f6c3f291f0f9f1521584e')