2022-11-18 19:11:48 +08:00
|
|
|
import _hashlib
|
|
|
|
|
|
|
|
|
|
|
|
def new(mode: str) -> _hashlib.Hash:
|
|
|
|
hash = _hashlib.Hash()
|
2022-11-19 18:37:01 +08:00
|
|
|
hash.new(mode, None)
|
2022-11-18 19:11:48 +08:00
|
|
|
return hash
|
|
|
|
|
|
|
|
|
2022-11-18 22:12:23 +08:00
|
|
|
def md5(data = None) -> _hashlib.Hash:
|
2022-11-18 19:11:48 +08:00
|
|
|
hash = _hashlib.Hash()
|
2022-11-19 18:37:01 +08:00
|
|
|
hash.new("md5", data)
|
2022-11-18 19:11:48 +08:00
|
|
|
return hash
|
|
|
|
|
|
|
|
|
2022-11-18 22:12:23 +08:00
|
|
|
def sha1(data = None) -> _hashlib.Hash:
|
2022-11-18 19:11:48 +08:00
|
|
|
hash = _hashlib.Hash()
|
2022-11-19 18:37:01 +08:00
|
|
|
hash.new("sha1", data)
|
2022-11-18 19:11:48 +08:00
|
|
|
return hash
|
|
|
|
|
|
|
|
|
2022-11-18 22:12:23 +08:00
|
|
|
def sha224(data = None) -> _hashlib.Hash:
|
2022-11-18 19:11:48 +08:00
|
|
|
hash = _hashlib.Hash()
|
2022-11-19 18:37:01 +08:00
|
|
|
hash.new("sha224", data)
|
2022-11-18 19:11:48 +08:00
|
|
|
return hash
|
|
|
|
|
|
|
|
|
2022-11-18 22:12:23 +08:00
|
|
|
def sha256(data = None) -> _hashlib.Hash:
|
2022-11-18 19:11:48 +08:00
|
|
|
hash = _hashlib.Hash()
|
2022-11-19 18:37:01 +08:00
|
|
|
hash.new("sha256", data)
|
2022-11-18 19:11:48 +08:00
|
|
|
return hash
|
|
|
|
|
|
|
|
|
2022-11-18 22:12:23 +08:00
|
|
|
def sha384(data = None) -> _hashlib.Hash:
|
2022-11-18 19:11:48 +08:00
|
|
|
hash = _hashlib.Hash()
|
2022-11-19 18:37:01 +08:00
|
|
|
hash.new("sha384", data)
|
2022-11-18 19:11:48 +08:00
|
|
|
return hash
|
|
|
|
|
|
|
|
|
2022-11-18 22:12:23 +08:00
|
|
|
def sha512(data = None) -> _hashlib.Hash:
|
2022-11-18 19:11:48 +08:00
|
|
|
hash = _hashlib.Hash()
|
2022-11-19 18:37:01 +08:00
|
|
|
hash.new("sha512", data)
|
2022-11-18 19:11:48 +08:00
|
|
|
return hash
|