我尝试生成加密的密码字符串,类似于Linux中的/etc/shadow。由于某些原因,我得到的输出是不同的。你知道我遗漏了什么吗?一个比另一个长(不算盐的部分)?在
#!/usr/bin/python
import crypt
alg = 6 # SHA512
salt = 'vb1tLY1qiY'
word = 'password'
insalt = '${}${}$'.format(alg, salt)
cryptWord = crypt.crypt(word, insalt)
print cryptWord
输出是:$6FMi11BJFsAc
如果我在Linux中这样生成:
^{pr2}$输出是:$6$vb1tLY1qiY$WFHTa6CRShEuKg63vuPTYOVRK1oQiM6johIEs2JslF1904VhEdSXlHje74eB4uLXHrKNyZ4bPjSlWpZD6qIo71
我可以使用lib。它不是作为python的一部分来安装的(至少在osx上),但是,您可以通过pip安装它。在
https://gist.github.com/hbeatty/25db5847e7068335681db88248d0deaf
相关问题 更多 >
编程相关推荐