RODY/app/utils/EncryptionTool.py

25 lines
535 B
Python
Raw Normal View History

2022-11-04 17:37:08 +08:00
import hashlib
import uuid
def sha256_encode(contents: str):
res = hashlib.sha256(b"%b" % contents.encode("utf8")).hexdigest()
return res
def sha3_256_encode(contents: str):
res = hashlib.sha3_256(b"%b" % contents.encode("utf8")).hexdigest()
return res
def generate_uuid():
return uuid.uuid4()
if __name__ == "__main__":
print(hashlib.algorithms_guaranteed)
print(hashlib.algorithms_available)
print(sha256("res"))
print(sha3_256("res" + generate_uuid().hex))
print(generate_uuid().hex)