|
|
地板

楼主 |
发表于 2008-3-14 12:17:09
|
只看该作者
Re: 请教一个hash的入门问题
The following is captured from 维基百科:
散列函数(或散列算法)是一种从任何一种数据中创建小的数字“指纹”的方法。该函数将数据打乱混合,重新创建一个叫做散列值的指纹。散列值通常用来代表一个短的随机字母和数字组成的字符串。好的散列函数在输入域中很少出现散列冲突。在散列表和数据处理中,不抑制冲突来区别数据,会使得数据库记录更难找到。
Hash function is used to generate "finger print" most of the time. Hash function can be any algorithm, but must guarantee different input, must generate different output (uniqueness). MD5 is a good example.
Example of hash can be used as password storage. The hash function itself is not reversible (You cannot provide an output to get the input), and thus the system does not know the original input. Following is an example:
Password = "123456";
Hash(Password) will generate something like "D2AC55";
Where "D2AC55" will be stored at the system. In future, when someone is asked to provide the password again, the system will do:
if (Hash(input_password) == "D2AC55")
then OK;
else WRONG_PASSWORD;
The system cannot generate "12345" by providing "D2AC55", and thus is quite safe. |
|