简体   繁体   English

PBKDF2是否生成唯一的哈希?

[英]Does PBKDF2 generate the unique hash?

I want to generate a hash of some data. 我想生成一些数据的哈希。 Going through some hash algorithms I could find out bcrypt and PBKDF best suitable for my application. 通过一些哈希算法,我可以找到最适合我的应用程序的bcrypt和PBKDF。 There might be the case that with the different data algorithm generates a same hash (like in MD5, it could generate the same hash for different sort of data). 可能存在这样的情况,即使用不同的数据算法会生成相同的哈希(就像在MD5中一样,它可能会为不同种类的数据生成相同的哈希)。

By the reviews of many expertise, bcrypt is the best secure hash algorithm and its provides uniqueness among different hashes. 通过许多专业知识的回顾,bcrypt是最好的安全哈希算法,它在不同哈希之间提供了唯一性。

But, does the PBKDF2 provides the uniqueness for hash? 但是,PBKDF2是否为哈希提供唯一性?

Edit 1 编辑1

I need to generate hash with the same input data (hash key will be generated more than one time for same input) but it should not generate same hash for different input data (might happens in some hash algorithms). 我需要使用相同的输入数据生成哈希(哈希键将为同一输入生成多次),但不应为不同的输入数据生成相同的哈希(某些哈希算法可能会发生这种情况)。

Algorithms such as one of the SHA-2 suffice. SHA-2之类的算法就足够了。 The hash generated is not unique to the message. 生成的哈希不是消息唯一的。 It is even true that there are an infinite number of messages that hash to the same value. 甚至确实有无数个散列为相同值的消息。 The trick is that it is impossible to find one of the other messages that create this hash. 诀窍是不可能找到创建此哈希的其他消息之一。

The chance of generating a collision when generating two hashes with different messages is equal to 1/2^256 for SHA-256. 对于SHA-256,当生成带有不同消息的两个哈希时,生成冲突的机会等于1/2 ^ 256。 You could however generate and store hashes and then calculate the chance that one of all the possible pairs is identical. 但是,您可以生成并存储哈希,然后计算所有可能的中的一个相同的机会。 In that case the birthday problem is in effect. 在这种情况下,生日问题就生效了。 That's why a hash only provides half the bits of security. 这就是为什么哈希仅提供一半安全性的原因。 So the chance of generating a collision giving 2^128 hashes is (about) 1/2^128 or 1 in 340282366920938463463374607431768211456. This is why you only have to worry about collisions in broken hash functions such as MD5 (and possibly SHA-1 in the near future). 因此,在340282366920938463463374374607431768211456中产生产生2 ^ 128个散列的冲突的可能性是(大约)1/2 ^ 128或1。这就是为什么您只需要担心散列哈希函数(例如MD5)中的冲突(以及SHA-1中的SHA-1)不久的将来)。

Actually the inner state of PBKDF2 is the same as the internal hash that is used. 实际上,PBKDF2的内部状态与所使用的内部哈希相同。 Using PBKDF2 (besides being a Key Derivation Function instead of a hash) won't help you at all. 使用PBKDF2(除了是键派生函数,而不是散列)完全不会帮助您。 It is just as vulnerable (or rather, not vulnerable) to collisions as the inner hash. 它与内部哈希一样容易受到碰撞(或更确切地说, 不是易受攻击)。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM