English 中文(简体)
What is hash exactly?
原标题:
  • 时间:2009-11-15 04:57:33
  •  标签:
  • hash
  • md5

I am learning MD5. I found a term hash in most description of MD5. I googled hash , but I could not find exact term of hash in computer programming.

Why are we using hash in computer programming? What is origin of the word??

最佳回答

I would say any answer must be guesswork, so I will make this a community wiki.

Hash, or hash browns, is breakfast food made from cutting potatoes into long thin strips (smaller than french fries, and shorter, but proportionally similar), then frying the mass of strips in animal or vegetable fat until browned, stuck together, and cooked. By analogy, hashing a number meant turning it into another, usually smaller, number using a method which still deterministically depending on the input number.

I believe the term "hash" was first used in the context of "hash table", which was commonly used in the 1960 s on mainframe-type machines. In these cases, usually an integer value with a large range is converted to a "hash table index" which is a small integer. It is important for an efficient hash table that the "hash function" be evenly distributed, or "flat."

I don t have a citation, that is how I have understood the analogy since I heard it in the 80 s. Someone must have been there when the term was first applied, though.

问题回答

A hash value (or simply hash), also called a message digest, is a number generated from a string of text. The hash is substantially smaller than the text itself, and is generated by a formula in such a way that it is extremely unlikely that some other text will produce the same hash value.

You re refering to the "hash function". It is used to generate a unique value for a given set of parameters.

One great use of a hash is password security. Instead of saving a password in a database, you save a hash of the password.

A hash is supposed to be a unique combination of values from 00 to FF (hexadecimal) that represents a certain piece of data, be it a file or a string of bytes. It is used primarily for password storage and verification, and to test if a file is the same as another file (i.e. you hash two files, if they match, they re the same file).

Generally, any of the SHA algorithms are preferred over MD5, due to hash collisions that can occur when using it. See this Wikipedia article.

According to the Wikipedia article on hash functions, Donald Knuth in the Art of Computer Programming was able to trace the concept of hash functions back to an internal IBM memo by Hans Peter Luhn in 1953.

And just for fun, here s a scrap of overheard conversation quoted in Two Women in the Klondike: the Story of a Journey to the Gold Fields of Alaska (1899):

They ll have to keep the hash table going all day long to feed us. T will be a short order affair.

the hash function hashes input to a value, requires a salt value and no proof salt is needed to store. Indications are everybody says we must store the salt same time match and new still work. Mathematically related concept is bijection

adding to gabriel1836 s answer, one of the important properties of hash function is that it is a one way function, which means you cannot generate the original string from its hash value.





相关问题
hmac-sha1 in ruby differs from C# HMACSHA1

I am trying to test the API from ankoder.com and have problem on the digest calculation for the authentication token . The sample is ruby while I am trying to call from C#. When I compare the digest ...

Make md5 strong

Im making a website that will intergrate with game that only support md5 hashing metod (atm). Which ofc is not especially safe anymore. But how could i make it stronger? Should I just generate long ...

Ordering a hash to xml: Rails

I m building an xml document from a hash. The xml attributes need to be in order. How can this be accomplished? hash.to_xml

Utility to hash and list files with identical contents?

UltraEdit saves temporary, ie. unsaved/untitled, files as (regex) "Edit.d+". When UltraEdit is killed (I do this when some software nags me to reboot), I noticed that it doesn t always save files in ...

How can I assign multiple values to a hash key?

For the sake of convenience I am trying to assign multiple values to a hash key in Ruby. Here s the code so far myhash = { :name => ["Tom" , "Dick" , "Harry"] } Looping through the hash gives a ...

Concurrent modification whilst traversing a ruby Hash

Suppose you had this: def wipeProduct(hash, nameToDelete) hash.each do |i| key = i[0] productName = i[1].first hash.delete(key) if productName==nameToDelete end end I m not sure it ...

Ruby (RoR) XML to hash and then show in views

I have some xml on server (http://server.com/my.xml). Here is the example: <?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE current PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3....

热门标签