哈希信息的目的是什么? [英] What's the purpose in hashing information?

查看:424
本文介绍了哈希信息的目的是什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在被教会如何在类中创建哈希表之后,我不明白哈希数据何时有用。在我看来,所有的哈希函数都是将数据以半随机位置存储在数组中。我想知道任何数据在存储后如何变得有用。



我的问题是:散列信息有益的一些示例是什么?如何以任何有组织的方式检索数据?它似乎被放置在任何难以找回的位置。

解决方案

散列可用于多种用途:


  1. 它可以用来比较大量的数据。您可以为数据创建哈希值,存储哈希值,之后如果要比较数据,则只需比较哈希值。


  2. 哈希可用于索引数据。它们可以用在散列表中以指向正确的行。如果您想快速查找记录,则计算数据的散列并直接转到相应散列记录指向的记录。 (这假定你有一个指向实际记录的哈希列表)

  3. >
  4. 散列可用于生成看似随机的字符串。



  5. 以下是维基百科列出的散列函数的应用:


    1. 查找重复记录 查找类似记录
    2. >查找类似的子字符串
    3. 几何哈希

    现在关于哈希表,这里是索姆e要点注意:

    如果您使用的是散列表,则表中的散列应以排序的方式排列。如果不是,您将不得不在哈希列上创建索引。有些实现会以散列的方式单独存储哈希,并指向原始记录。



    如果有人以半随机顺序存储散列值,则必须是因为上述原因或者他们只是想存储信息的消息摘要以进行比较,查找重复项等,而不是作为数据的索引。


    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 semi-random positions in an array. I want to know how any of the data can be made useful after it's stored.

    My question is this: what are some examples where hashing information is beneficial? How is data retrieved in any organized manner? It seems to be placed in arbitrary positions where it would be difficult to retrieve.

    解决方案

    Hashing can be used for many purposes:

    1. It can be used to compare large amounts of data. You create the hashes for the data, store the hashes and later if you want to compare the data, you just compare the hashes.

    2. Hashes can be used to index data. They can be used in hash tables to point to the correct row. If you want to quickly find a record, you calculate the hash of the data and directly go to the record where the corresponding hash record is pointing to. (This assumes that you have a sorted list of hashes that point to the actual records)

    3. They can be used in cryptographic applications like digital signatures.

    4. Hashing can be used to generate seemingly random strings.

    Here are the applications of hash functions that wikipedia lists:

    1. Finding duplicate records
    2. Finding similar records
    3. Finding similar substrings
    4. Geometric hashing

    Now regarding hash table, here are some points to note:

    If you are using a hash table, the hashes in the table should be in a sorted manner. If not, you will have to create an index on the hash column. Some implementations store the hash separately in a sorted manner and point to the original record.

    If somebody is storing hashes in a semi-random order, it must be either because of the above reasons or because they just want to store the message digest of the information for comparing, finding duplicates etc. and not as an index to the data.

    这篇关于哈希信息的目的是什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆