开发者

How does the Enterprise Library's CryptographyManager.CompareHash method work?

开发者 https://www.devze.com 2023-02-11 18:28 出处:网络
I\'ve been wondering how the CryptographyManager is able to compare a salted hash with the plain text. It has to save the salt for each hash somewhere, right? Has anyone any insig开发者_运维问答ht on

I've been wondering how the CryptographyManager is able to compare a salted hash with the plain text. It has to save the salt for each hash somewhere, right? Has anyone any insig开发者_运维问答ht on this?


We ship source code. Take a look at CryptographyManagerImpl.cs in the Cryptography solution. Also, you may want to review our unit tests - the ones that start with HashProvider should give you additional insight.


So I checked out the source code and it is actually quite trivial: The salt is prepended to the actual hash value. When the hash is compared to a plaintext the salt is extracted and used to hash the plaintext. These two hash values (= salt + hash) are then compared.

0

精彩评论

暂无评论...
验证码 换一张
取 消