谁能描述密码加密和哈希(sha-256)之间的区别?
我需要将密码保存到数据库。我对加密、使用 sha-256 的哈希、盐生成方法感到困惑。如果有人解释这背后的基本概念,那么它将很有帮助
I need to save the password to database.I get confused in encryption,hash using sha-256 ,salt generation method .If any one explains the basic concept behind this then it will be helpful
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
无论如何,下面是一个非常基本的解释......
The follow is a very basic explanation, anyway...
简而言之:
加密是一个逆过程。换句话说:如果我加密一些文本,有一个过程可以将新文本转换回原始文本,称为解密。
散列与加密有根本的不同,因为它没有这样的过程。哈希的目的是为您提供一个结果,该结果对于给定的输入文本是唯一的(好吧,几乎是唯一的,让我们保持唯一)。这样,人们可以验证两个输入文本是否相等,而无需知道实际输入文本是什么。因此,即使人们拿到了您的哈希密码,他们仍然无法解密。 SHA 是一系列提供散列的方法。
Salts and Peppers 只是散列的附加技术,它描述了在散列之前在输入文本之前和之后添加某些内容的过程。这提高了将哈希值暴力破解回文本的难度。
暴力破解意味着简单地尝试所有可能的输入(aa、ab、ac 等),看看是否可以生成与通过黑客攻击某个网站或其他方式获得的哈希值相匹配的哈希值。您可以在这里找到更多相关信息:https:// security.stackexchange.com/questions/3272/password-hashing-add-salt-pepper-or-is-salt-enough
In short:
Encryption is a process with an inverse. In other words: If I encrypt some text, there is a process which is able to convert the new text back to the original, called decryption.
Hashing is fundamentally different from encryption, because it does not have such a process. What a hash is meant to do is provide you with a result, which is unique for that given input text (well, almost unique, let's keep it at unique). This way, people can verify if two input texts were equal, without knowing what the actual input text was. So, if people get their hands on your hashed password, they still cannot decrypt it. SHA is a family of methods which provide hashing.
Salts and Peppers are merely additional techniques to hashing, which describe the process of adding something before and after the input text before hashing. This improves the difficulty of brute-force cracking of hashes back to text.
Brute force cracking means simply trying all possible inputs (aa, ab, ac, etc...) and see if you can generate a hash which matches the hash you have gotten via hacking some website or whatever. You can find more on that here: https://security.stackexchange.com/questions/3272/password-hashing-add-salt-pepper-or-is-salt-enough