Skip to main content
 首页 » 编程设计

python之保存散列密码之安全吗

2025年05月04日9开发

像这样的 Python 脚本可以安全使用吗?磁盘上会有一个文件“theFile”:

myPassHash = theFile.read() 
enteredPassword = raw_input("Enter your password: ") 
enteredHash = hashlib.sha512(enteredPassword) 
if myPassHash == enteredHash: 
    print "Correct!" 
else: 
    print "Incorrect!" 

请您参考如下方法:

这看起来很容易受到彩虹表攻击,因为您没有对密码加盐。

有关盐的更多信息(以及为什么推出自己的身份验证机制是个坏主意),请阅读 Eric Lippert's fabulous series关于密码加盐。