简体   繁体   English

散列算法的测试平台过程是什么?

[英]What is the testbench process for hashing algorithms?

Suppose that I wrote an implementation of a standard algorithm such as an MD* or a SHA*: How I know that it's correct ? 假设我编写了一个标准算法的实现,例如MD *或SHA *:我怎么知道它是正确的? Different implementations of the same algorithm must produce the same digest ? 同一算法的不同实现必须产生相同的摘要?

The reference documents themselves contain a small number of example cases, which can be used. 参考文档本身包含少量可以使用的示例案例。 (The hash of "abc" is in all of the reference documents, for example.) In addition, Aaron Gifford has made a number of test cases available at http://www.adg.us/computers/sha.html . (例如, "abc"的散列在所有参考文档中。)此外,Aaron Gifford在http://www.adg.us/computers/sha.html上提供了许多测试用例。 In particular, he has tests for some of the border cases (where the text is exactly the length of a block, or one less, and a couple of other special lengths. If your implementation calculates the correct value for all of these, there is a good chance that it is correct. 特别是,他测试了一些边界情况(文本正好是一个块的长度,或者少一个,以及其他一些特殊长度。如果你的实现计算所有这些的正确值,那么它很有可能是正确的。

Yes this is the case. 是的,情况就是这样。 However some hash algorithms come with variations/settings, so you will need to match those if that is the case. 但是,某些散列算法会带有变体/设置,因此如果是这种情况,您需要匹配这些算法。

A good example is how an MD5 is often given to allow you to verify your download was correct. 一个很好的例子是如何经常给出MD5以允许您验证下载是否正确。 In order for this to work the MD5 hash implementation needs to produce the same result for all implementations. 为了使其工作,MD5哈希实现需要为所有实现产生相同的结果。

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

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