What's the purpose in hashing information?

前端 未结 5 436
时光说笑
时光说笑 2021-01-31 10:44

After being taught how to create a hash table in class, I don\'t understand when hashing data would be useful. It seems to me that all hashing does is storing information in se

5条回答
  •  逝去的感伤
    2021-01-31 11:27

    There are a couple of typical reasons to hash data. In the example you reference, you would hash the data and use that as a key to extract the actual value of the hashed item. The hashed data is often referred to as a key and it references a bucket where the actual, non-hashed value can be found.

    The other typical reason is to create a signature of the hashed value so that you can check if the value has been changed by someone else. Since it's usually rare, depending on the algorithm used, to have two items hash to the same value, you can rehash a value and compare it to the saved hash value to check if the item is still the same.

提交回复
热议问题