MCPcopy Index your code
hub / github.com/vastsa/FileCodeBox / hash_password

Function hash_password

core/utils.py:102–109  ·  view source on GitHub ↗

使用 SHA256 + salt 哈希密码 返回格式: sha256$ $

(password: str)

Source from the content-addressed store, hash-verified

100
101
102def hash_password(password: str) -> str:
103 """
104 使用 SHA256 + salt 哈希密码
105 返回格式: sha256$<salt>$<hash>
106 """
107 salt = os.urandom(16).hex()
108 password_hash = hashlib.sha256(f"{salt}{password}".encode()).hexdigest()
109 return f"sha256${salt}${password_hash}"
110
111
112def verify_password(password: str, hashed: str) -> bool:

Calls

no outgoing calls