This commit is contained in:
Miloslav Ciz 2023-02-01 22:29:15 +01:00
parent 253e6f22f2
commit ae2c2384b2
3 changed files with 33 additions and 3 deletions

View file

@ -17,7 +17,9 @@ It is generally given that a hash (or hash function) should satisfy the followin
- **Minimize collisions**, i.e. the probability of two different values giving the same hash. Mathematically collisions are always possible if we're mapping a big space onto a smaller one, but we should try to reduce collisions that happen in practice. This property should follow from the principle of uniformity and chaotic behavior mentioned above.
- **Be difficult to reverse** (mainly for security related hashes). Lots of times this comes naturally from the fact that a hash maps a big space onto a smaller space (i.e. it is a non-[injective](injective.md) function) and from their chaotic nature. Hashes can typically be reversed only by [brute force](brute_force.md).
Hashes are similar to [checksums](checksum.md) but are different: checksums are simpler because their only purpose is for checking data integrity, they don't have to have a chaotic behavior, uniform mapping and they are often easy to reverse. Hashes are also different from database IDs: IDs are just sequentially assigned numbers that aren't derived from the data itself, they don't satisfy the hash properties and they have to be absolutely unique.
Hashes are similar to [checksums](checksum.md) but are different: checksums are simpler because their only purpose is for checking data integrity, they don't have to have a chaotic behavior, uniform mapping and they are often easy to reverse. Hashes are also different from database IDs: IDs are just sequentially assigned numbers that aren't derived from the data itself, they don't satisfy the hash properties and they have to be absolutely unique. The term **pseudohash** may also be encountered, it seems to be used for values similar to true hashes which however don't quite satisfy the definition.
{ I wasn't able to find an exact definition of *pseudohash*, but I've used the term myself e.g. when I needed a function to make a string into a corresponding fixed length string ID: I took the first N characters of the string and appended M characters representing some characteristic of the original string such as its length or checksum -- this is what I called the string's pseudohash. ~drummyfish }
Some common uses of hashes are: