用盐散列在SHA512中? - Python [英] Hashing in SHA512 using a salt? - Python

查看:110
本文介绍了用盐散列在SHA512中? - Python的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我一直在浏览hashlib文档,但没有发现有关在哈希数据时使用的任何讨论.

I have been looking through ths hashlib documentation but haven't found anything talking about using salt when hashing data.

帮助会很棒.

推荐答案

Samir的答案是正确的,但有些含糊.基本上,salt只是数据的随机衍生位,您可以在数据前添加前缀或后缀,以显着增加对哈希值进行字典攻击的复杂性.因此,给定盐s和数据d,您只需执行以下操作即可生成数据的盐化哈希值:

Samir's answer is correct but somewhat cryptic. Basically, the salt is just a randomly derived bit of data that you prefix or postfix your data with to dramatically increase the complexity of a dictionary attack on your hashed value. So given a salt s and data d you'd just do the following to generate a salted hash of the data:

import hashlib
hashlib.sha512( s + d ).hexdigest()

有关更多详细信息,请参见此维基百科文章

See this wikipedia article for more details

这篇关于用盐散列在SHA512中? - Python的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆