Questions tagged [hash-function]

For questions about hash functions: functions from a big set to a smaller one such that the same output $f(x_1)=f(x_2)$ for different input $x_1\ne x_2$ is unlikely, especially if $x_2$ differs from $x_1$ by a random error or is crafted by an adversary.

253 questions
14
votes
3 answers

How to classify polyominoes by shape

I am trying to find a robust way to classify and distinguish polyominoes. I would like to write a simple algorithm that could identify similar free polyominoes (under translation, rotation, reflection or glide reflection), given a set. Since I am…
13
votes
3 answers

Curious Properties of 33

Because my explanation has so many words, I'll start with my question and then you can read the explanation if you need to: The Bernstein Hash method uses the number 33 as a multiplier. From what I've read Bernstein himself has no reasonable…
11
votes
0 answers

How to attack universal hash function based on finite-field arithmetic?

As per the Recursive n-gram hashing is pairwise independent, at best paper, I want to use the algorithm described in chapter 6 and 7 (page 7 - 10). The hash works as follows: Define a random function $h_1$ that maps elements in a set $B$ to…
8
votes
6 answers

Hide my invoice number

I'm not a mathematician, so please forgive any ignorance. I have a small business - I'm generating invoices incrementally. I'm currently on about invoice number 4000. I guess I don't want my customers knowing how much business I'm doing (i.e. if…
Eamorr
  • 225
7
votes
1 answer

Analysis of a calculation of expected number of collisions in hashing

For a formal problem statement, I quote from the text Introduction to Algorithms by Cormen et. al Suppose we use a hash function $h$ to hash $n$ distinct keys into an array $T$ of length $m$. Assuming simple uniform hashing, what is the expected…
7
votes
2 answers

What's the difference between a fingerprint and a hash?

My understanding is that both a fingerprint and a hash are functions that take as input some arbitrarily long bitstring, and output a bitstring of a fixed size. The Wikipedia page for Hash Functions says: Hash functions are related to (and often…
6
votes
3 answers

Calculate unique Integer representing a pair of integers

I have a pair of positive integers $(x, y)$, with $(x, y)$ being different from $(y, x)$, and I'd like to calculate an integer "key" representing them in order that for a unique $(x, y)$ there is an unique key and no other pair $(w, z)$ could…
IggY
  • 207
6
votes
1 answer

Hash function and one near hard example?

Example: Suppose $H:${$1,...,n$} $\rightarrow ${$1,..,n$} be a uniform hash function. for input $x$, $z$ is equal to number of trailing zero in the right side of $H(x)$. for $0 \leq c \leq 1$ what is the order of probability $ z \geq c \log_2 n$?…
6
votes
0 answers

Bloom Filter with an interval input

I have been trying to design a variant of a bloom filter that can insert an interval of values at once, as well as query if a certain interval is in the bloom filter. I haven't been able to think of a faster case than the naive method of inserting…
bloom
  • 131
6
votes
0 answers

Bloom filter optimization on an interval of inputs

I'v been tackling a problem with bloom filters. I have a basic version working on paper, but I need to be able to put a large interval of numbers into the filter at a given time. Let I be an interval within [0,U]. The problem is to put I into set S,…
bloom
  • 131
6
votes
2 answers

Finding a minimal perfect hash function for small sets quickly

I'm trying to solve the computer science problem "Minimal perfect hash function" (MPHF). I have an algorithm that can generate a MPHF for very large sets in $O(n)$ that only needs 1.54 bits/key, very close to the theoretical limit of 1.44 bits/key,…
5
votes
2 answers

Toy cryptographic hash function for education purposes?

I'm teaching some high school students about number theory and cryptography, and I'd like a hash function (or ideally, a family of hash functions) that I can use as simple demonstration for cryptographic hash functions. The students have learned…
RichN
  • 71
5
votes
1 answer

Mathematical notation for Hash Tables

A matrix is nice for modelling arrays, eg const A = [1, 2, 3, 4] const a1 = A[0] const a2 = A[1] const a3 = A[2] const a4 = A[3] can be modelled with $$ A = \begin{bmatrix} 1\\ 2\\ 3\\ 4 \end{bmatrix} $$ $$ a1 = A_1\\ a2 = A_2\\ a3 = A_3\\ a4 =…
Dmytro
  • 1,165
5
votes
2 answers

How can I convert this unique string of characters into a unique number?

I have an unusual programming problem and the math side of it has me stumped. It's probably a simple answer but math isn't my strongest area. I've generated a unique string of 7 characters which are each randomly selected from these possibilities:…
J.Todd
  • 253
5
votes
2 answers

An efficient way to find anagrams

Consider a set of words where you want to divide the set into subsets of words, where all members of each subset are anagrams (same letters, different arrangement). You can do this computationally in several ways, the "best" way is sorting the…
1
2 3
16 17