Questions tagged [hash]

Mathematical function that maps arbitrarily-sized data to fixed-size integers, often used as keys in hash tables or to help ensure data integrity

A hash function maps data structures of any size to fixed-length integers, with the intent that different data map to different integers. Some important kinds of hash functions are

345 questions
112
votes
7 answers

Why is it best to use a prime number as a mod in a hashing function?

If I have a list of key values from 1 to 100 and I want to organize them in an array of 11 buckets, I've been taught to form a mod function $$ H = k \bmod \ 11$$ Now all the values will be placed one after another in 9 rows. For example, in the…
CodyBugstein
  • 3,017
  • 11
  • 31
  • 46
34
votes
5 answers

Is there an anti-Bloom filter?

A Bloom filter makes it possible to efficiently keep track of whether various values have already been encountered during processing. When there are many data items then a Bloom filter can result in a significant memory saving over a hash table. …
19
votes
2 answers

Could quantum computing eventually be used to make modern day hashing trivial to break?

Simply put, if one were to build a quantum computing device with the power of, say, 20 qubits, could such a computer be used to make any kind of modern hashing algorithm useless? Would it even be possible to harness the power of quantum computing…
hakusaro
  • 325
  • 3
  • 9
14
votes
2 answers

Function that spreads input

I'd like to know if there is a function $f$ from n-bit numbers to n-bit numbers that has the following characteristics: $f$ should be bijective Both $f$ and $f^{-1}$ should be calculable pretty fast $f$ should return a number that has no…
fuz
  • 913
  • 6
  • 20
14
votes
9 answers

Do passwords need a max length?

I understand that password storage generally uses hashing for security due to it being irreversible and that the stored hash is just compared to the hash of the password inputed by a user attempting to log in. As hashes are fixed length, does that…
Ethan
  • 241
  • 2
  • 3
13
votes
2 answers

Fast hashing: combination of different techniques to identify changes in a file?

I want to create a fast way to detect whether a file might or might not be the same. For almost 100% sureness I would use an existing hash algorithm, e.g. SHA256. However, the files are expected to be huge video files with several GB, so calculating…
Thomas Weller
  • 271
  • 2
  • 9
10
votes
3 answers

Why is a (collision-less) hashtable lookup really O(1)?

Disclaimer: I know there are similar sounding questions already here and on Stackoverflow. But they are all about collisions, which is not what I am asking for. My question is: why is collision-less lookup O(1) in the first place? Let's assume I…
Foo Bar
  • 203
  • 1
  • 7
10
votes
2 answers

Weak hashing function for memorable IPv6 addresses

IPv6 addresses in the form of 862A:7373:3386:BF1F:8D77:D3D2:220F:D7E0 are much harder to memorize or even transcribe than the 4 octets of IPv4. There have been attempts to mitigate this, making IPv6 addresses somehow more memorable. Is there an…
Jason Kleban
  • 557
  • 3
  • 12
10
votes
1 answer

Are there associative cryptographic / collision resistant hashes?

Git uses SHA hashing as a content address key. This relies on their being a vanishingly small probability that two different pieces of content will ever hash to the same key. For content c with length l(c), SHA(c) can be computed in time O(l(c)) and…
Benjohn
  • 273
  • 1
  • 6
9
votes
2 answers

Hash size: Are prime numbers "near" powers of two a poor choice for the modulus?

Cormen et al.'s "Introduction to Algorithms" says the following about the division method hash function $h(k)=k \text{ mod } m$: A prime not too close to an exact power of 2 is often a good choice for $m$. For example, suppose we wish to allocate a…
9
votes
2 answers

How to avoid cascading resizes when resizing hash tables?

With conventional collision resolution methods like separate chaining and linear/quadratic probing, the probe sequence for a key can be arbitrarily long - it is simply kept short with high probability by keeping the load factor of the table low.…
Anonymous
  • 89
  • 1
9
votes
1 answer

Attack on hash functions that do not satisfy the one-way property

I am revising for a computer security course and I am stuck on one of the past questions. Here is it: Alice ($A$) wants to send a short message $M$ to Bob ($B$) using a shared secret $S_{ab}$ to authenticate that the message has come from her. She…
sam
  • 357
  • 2
  • 7
8
votes
1 answer

Is there a continuous hash?

Questions: Can there be a (cryptographically secure) hash that preserves the information topology of $\{0,1\}^{*}$? Can we add an efficiently computable closeness predicate which given $h_k(x)$ and $h_k(y)$ (or $y$ itself) tells us if $y$ is very…
Kaveh
  • 22,661
  • 4
  • 53
  • 113
8
votes
2 answers

How does taking modulo 1 make sense?

I need some help understanding the problem statement in CLRS 11.3-4 pg 269. It says: Consider a hash table of size $m = 1000$ and a corresponding hash function $ h(k) =\left \lfloor m(kA \bmod 1) \right \rfloor $ for $A = (\sqrt5 - 1)/2$.…
Parag
  • 340
  • 1
  • 2
  • 6
7
votes
1 answer

Most space-efficient lossy dictionary?

Short version: What is the most space-efficient lossy dictionary (with given false positive and false negative rates)? Long version: A lossy dictionary is a data structure $D$ that encodes a set $S$ of $n$ key-value pairs $(k_i, v_i)$, assorted with…
1
2 3
22 23