Answer the question
In order to leave comments, you need to log in
What hashcode is ideologically correct?
There was a small question about the hash-tions and generally about the hash code.
I know what a hash function is and about its features (well, about the application environments).
In my understanding, such a function takes an argument as input and already returns some number. Depending on the type of the argument, the calculation algorithm also changes. But the most common example is a hash of a string.
That is, let's say:
// Return number
function hashcode(arg) {
...
}
hashcode("abracadabra");
aVdxYYbs
. Doesn't that violate the hashcode rules (that it should only be a number)? Or am I wrong?
Answer the question
In order to leave comments, you need to log in
There are so-called cryptographic hashes, whose task is to make the generation of two documents with the same hash computationally impossible. If the hash is extended by two bits, this task becomes more difficult, as far as I know, not four times, but twice.
Because cryptographic hashes are huge (obsolete MD5 is 16 bytes, most modern ones are 32 or 64). How to write it to the database, if there is not always such a type, and BLOBs are firing from a cannon at ants? Somehow to encode in a line. In addition, there are places on the web where binary data does not roll even without string coding in any way (for example, URLs).
The author is obviously a man from the Perl/PHP camp, and in addition to computing the hash, took and coded it. Probably the BASE64 method (8 BASE64 characters correspond to a 6-byte hash). Why encode ordinary, non-cryptographic hashes like this - I don’t know at all!
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question