0%
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
| from hashlib import sha1, sha256, sha384, sha512
def encrypt_sha1(s): obj_sha1 = sha1() obj_sha1.update(s.encode(encoding='utf-8')) return obj_sha1.hexdigest()
def encrypt_sha256(s): obj_sha256 = sha256() obj_sha256.update(s.encode(encoding='utf-8')) return obj_sha256.hexdigest()
def encrypt_sha384(s): obj_sha384 = sha384() obj_sha384.update(s.encode(encoding='utf-8')) return obj_sha384.hexdigest()
def encrypt_sha512(s): obj_sha512 = sha512() obj_sha512.update(s.encode(encoding='utf-8')) return obj_sha512.hexdigest()
if __name__ == '__main__': print(encrypt_sha1('admin')) print(encrypt_sha256('admin')) print(encrypt_sha384('admin')) print(encrypt_sha512('admin'))
|