原文档中的表述为:
SHA256 hash of password
Example: hashed_password_string
经过实际测试,依照文档描述为密码进行SHA256哈希,即sha256(password.encode()).hexdigest()生成的哈希并不能成功登录。
摸排源代码得知,相关代码位于https://github.com/OpenListTeam/OpenList/blob/main/internal/model/user.go#L157,实际上是一个加盐哈希算法,而不是文档中描述的“密码的SHA256哈希”。Salt为固定值https://github.com/alist-org/alist。
因此,以下写法才是符合事实的
STATIC_HASH_SALT = "https://github.com/alist-org/alist"
combined = f"{password}-{STATIC_HASH_SALT}"
hashed_password = sha256(combined.encode()).hexdigest()