【发布时间】:2008-10-17 08:55:21
【问题描述】:
我有点困惑,加密函数的参数是一个字符串。我是否应该简单地用 str() 包装非字符串参数,例如
hashlib.sha256(str(user_id)+str(expiry_time))
hmac.new(str(random.randbits(256)))
(暂时忽略 random.randbits() 可能在密码学上不好)。 编辑:我意识到 hmac 示例很愚蠢,因为我没有将密钥存储在任何地方!
【问题讨论】:
标签: python cryptography