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
332
questions
10
votes
1
answer
605
views
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 ...
0
votes
1
answer
25
views
Determine if all the continuous subsequences of an array contain at least one unique element in O(n lgn)
Given an array of length n, how to determine if all the continuous subsequence of this array contains at least one unique element.
Any subarray array[start, end] ...
0
votes
1
answer
40
views
How to create a 'hashing' function that maps up to 1 to N numbers uniquely to numbers 1 to N
I would like to use or create a hashing algorithm that takes K inputs from 1 to N and maps them uniquely to different numbers on 1 to N. K can be 1 to N. Ideally I would like the hashing alg to be ...
0
votes
1
answer
57
views
What would happen SHA-256 collision were to be found?
As far as I and this wikipedia page know, there are no collisions (2 inputs with the same output) found in SHA-256 (yet).
what would happen if a collision were to be found,
1. would it be easier to ...
0
votes
0
answers
16
views
Suppose some hash family H satisfies $$Pr_{h_{\in_{R}} H}[h(x_1) = h(x_2)] = \frac{1}{|Y|}$$ Does it mean H is 2 universal?
Suppose some hash family H satisfies $$Pr_{h_{\in_{R}} H}[h(x_1) = h(x_2)] = \frac{1}{|Y|}$$ Does it mean H is 2 universal?
The converse is true, but I'm not sure about this.
2
votes
1
answer
39
views
What is the definition of security of universal hashing
As a cryptographic primitive, universal hashing should have somewhat a criterion on its security. How is its (computational) security defined? Or, in other words, what "breaks" a universal ...
13
votes
9
answers
7k
views
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 ...
0
votes
1
answer
39
views
On the equivalence between two definitions of universal hashing
Let $H=\{h|h:X\to Y\}$, $|X|=n$, $|Y|=m$. $H$ is a universal hash family if
Def 1. For any $x_1,\ x_2\in X$, $x_1\neq x_2$, $\left|\left\{h\in H\middle| h(x_1)=h(x_2)\right\}\right|\leq |H|/m$. (or ...
0
votes
0
answers
25
views
If the data that I input for locality sensitive hashing is sensitive, should its resulting hash also be considered sensitive?
Is it correct to assume that if the input that I hash is sensitive, that I should also consider the locality-sensitive hash generated for that input to be sensitive? I presume that, if an attacker has ...
0
votes
0
answers
60
views
Universal hash functions and prime number modulus scheme
Definition of a universal hashing function $h: U \rightarrow[m]$ (where $[m]=\{0, \ldots, m-1\}$) is that for any given distinct keys $x,y \in U$, when $h$ is picked at random (independently of $x$ ...
0
votes
1
answer
16
views
Reversible computing as a path to a useful PRNG or hash function?
There's a question I've long had about reversible computing: do non-trivial algorithms usually end up generating strongly pseudorandom data as an artifact of the computation?
The most straightforward ...
4
votes
1
answer
94
views
Self referential hash function possible?
Is there a hashing function $f$ that for each input $x$ if $f(x) = y$, then $f(x \, || \, y) = y$? In other words, if we concatenate its output with the input, the result will not change.
Furthermore, ...
1
vote
2
answers
123
views
Perfect ordered hash function on ordered sequence
I have a sequence of integer tuples $t_1, t_2,..., t_N$ of different sizes in lexicographic order, e.g.:
$(1, 1), (1, 2), (1, 3, 5), (1, 3, 6), (1, 5), (3), (3, 2, 3), (3, 7), (3, 8, 1), ...$
...
1
vote
0
answers
66
views
How to properly save Zobrist Keys?
In a project of mine, I want to represent states as efficiently as possible. Initially, I went ahead with a BitBoard representation and some clever tricks to speed up the evaluation of the game tree. ...
0
votes
0
answers
54
views
In the complexity of open addressing, why it is necessary take the sum to $\infty$?
When estimating the average calculation complexity of open addressing,
I found following explanation:
Let $B$ be the number of backets and $N$ be the number of elements already in the hash table.
The ...
1
vote
1
answer
75
views
Perfect hash function that weakly preserves leading zeros
I need a perfect hash function that maps 2 integers into one integer twice the size (i.e. $(Int64, Int64) \rightarrow Int128$).
The function preserves sum of leading zero bits:
$(0, 0) \rightarrow 0$ ...
0
votes
1
answer
124
views
Simple Uniform hashing with chances of no collision
I know that if I have $n$ different values in an array of size $m$ (where $m>n$) under simple uniform hashing, the average probability of the total number of collisions is:
$$\sum_{i=1}^{n-1}\frac{...
1
vote
2
answers
101
views
Order-preserving hashtable for integer tuples
There are integer tuples which index cells of a sparse multi-dimensional array (points inside n-parallelepiped), $n \le 32$.
The array itself is a BST with keys formed as $key = (...((a_0 * S_1 + a_1) ...
1
vote
2
answers
153
views
How to use a worst case scenario in Rolling Hash: Rabin Karp Algorithm when the given string only contains the occurrences of "a and b?"
Issue: I am having a hard time figuring out how to use the worst case for Rolling Hash, especially if the occurrences are only "a and b" for the string. Not only that but it is a bit of a ...
0
votes
0
answers
59
views
Why using nC2*1/365 to calculate the birthday paradox is incorrect
The birthday paradox is basically that assume there are 365 days in a year(ignore the effect of Febuary 29th), each person's birthday is uniformly random in these 365 days and independent with others. ...
0
votes
2
answers
53
views
Is there any algorithm to find all unique pairs of People with age equal to a given number in less than O(n²)
I have a problem where I have to find all the pairs of a list of People where the sum of their age is equal to a given number under time complexity less than
O(N²)
...
1
vote
1
answer
30
views
Sampling unique records from a large dataframe
Suppose we have a dataframe with ~10M rows with ~9M duplicate records. What is the most time efficient way of selecting the unique records from this dataframe?
Some sort of sampling algorithm?
0
votes
1
answer
55
views
Universal family of hash functions — dependent on table size?
Given the following family of hash functions:
$$
\mathbb{H} = \{h_c(x) = (12x + c) \bmod
m \mid c \in \mathbb{N} \},
$$
where $m$ is the key size.
Prove that $\mathbb{H}$ is not a universal ...
-5
votes
1
answer
512
views
Implementing Flajolet–Martin algorithm in Python
I am stuck on what to do.
I am trying to create a simple implementation of the Flajolet–Martin algorithm using Python. The stream will be the contents of a text file and you will produce an ...
0
votes
2
answers
200
views
the load factor in hash table
What is numerically the best value or range of values used as a reference for the load factor used in the hash table?
What is the pseudo-code of the “rehashing” method, which is applied when many ...
1
vote
1
answer
357
views
Hash / Compression algorithm to shorten text?
I desperately need a hash / compression function that is suited to shorten text.
The context is this: I want to bring order and sort my box with hundreds of charging adapters (duh). After I determined ...
0
votes
1
answer
139
views
Consistent Hashing Algorithm Without Distribution / Load Balancing
I need some help finding or creating a consistent hashing algorithm with the following properties:
Given N buckets, only distributes keys to bucket N.
When number of buckets are increased from N to N+...
1
vote
2
answers
1k
views
Averege time complexity of open addressing
I get that it depends from the number of probes, so by how many times the hash code has to be recalculeted, and that in the best case there will only be one computation of the hash code and the ...
1
vote
0
answers
38
views
Where does 2^32 come from with bitcoin?
Several months ago I was doing research into calculating mining revenue for several crypto currencies. When trying to calculate BTC revenue I found this value 1/2^32 which was described somewhere ...
2
votes
1
answer
57
views
How do these Crypto terms relate to each other and what do they all mean?
Alright this is another day of my pursuit to learn about how crypto works. I have several terms that I have found linked together. I was trying to do research on how the Target Hash is determined and ...
0
votes
2
answers
46
views
What happens in the event of a collision in a crypto hash function?
I was reading about hash functions in crypto and a website had mentioned that they were collision free, which obviously isn't possible if there are infinite input values that are mapped to outputs of ...
1
vote
0
answers
21
views
Algorithm Complexity Question
this is my first question on this site and I would like to preface this by saying I am not very savvy when it comes to Computer Science. So, I will try to ask this the best I can.
I was doing some ...
1
vote
1
answer
48
views
Locality Sensitive Hashing for Sets
Are there locality sensitive hashes that work nicely with sets? Each set would get a hash, the order of the elements in the set does not change the hash, and sets that share more elements are closer ...
2
votes
1
answer
84
views
Splitting the output of a wide hash in lieu of multiple independent hashes
Certain algorithms require two independent hash functions. An optimization I've seen is to split the output of a wide hash function and use the parts instead of the two independent hash functions of ...
1
vote
1
answer
360
views
Optimal parameters for a Bloom filter
My first question here. Please do not judge me much if this is a too simple.
Some text consists of $n=12\,500$ distinct words. I would like to construct a Bloom filter with $\epsilon=10^{-2}$ ...
0
votes
1
answer
36
views
Confused about the appropriate slot in linear probing
The following paragraph is from the book CLRS:
Given an ordinary hash function $h' : U \rightarrow \{0, 1, ..., m - 1\}$, which we refer to as an auxiliary hash function, the method of linear probing ...
1
vote
1
answer
42
views
Fingerprint functions for set equality checks?
Given I have two sets of objects $A =\{a, b, c\}$ and $B = \{a, b, c, a\}$
Based on the set equality, I want the fingerprint of these sets to be the same $F(A) = F(B)$.
Additionally I want to be able ...
2
votes
1
answer
134
views
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$. ...
0
votes
1
answer
71
views
Finding a hash function, so that the set of hash functions is universal
Problem:
Let $U = \{0,1,2,3,4,5\}$ be a universe of keys and $T = \{0,1,2\}$ we observe follwing 5 hash functions which map from $U$ to $T$ :
$$h_1(x) = (x+1) \mod{3} \hspace{5mm} h_2(x) = (x+2) \mod{...
0
votes
3
answers
150
views
How do i delete one single unequal element from an array of equal elements without using hashing?
The rules of the question state that:
Only one element is different.
Rest are all same.
Array A size is 8.
I need to find the different element and remove it (Hashing cannot be used).
I have not ...
1
vote
1
answer
57
views
How to efficiently see if a value is in a set
I was curious is there a really efficient way to see if a value is in a set? This question comes from me thinking about youtube views. As far as I understand youtube view count goes up for every ...
3
votes
1
answer
320
views
A question about hash problems in CLRS book
Consider the following problem 11.2-6 from CLRS book:
Suppose we have stored $n$ keys in a hash table of size $m$, with collisions resolved by chaining, and that we know the length of each chain, ...
1
vote
1
answer
178
views
A hash function for a 2D hash table with a scattering property?
I have an $n\times n$ matrix, and want to find a bijective function $h:[n^2] \to [n]\times [n]$ that can act as a hash function to map the numbers 1 through $n^2$ to row/column indices in my matrix. ...
1
vote
0
answers
48
views
Check if string contains pattern (with respect to one-to-one symbols mapping) [closed]
I'm trying to solve following problem:
Check, if the string contains substring, that can be obtained from pattern using one to one lower case symbols replacement (using bijection between original ...
1
vote
1
answer
110
views
Expected Lookup Length in Open Addressing Hash Table with Simple Uniform Hashing
In several proofs of the expected lookup length in an open addressing hash table, an assumption is made (which is said to follow from the "simple uniform hashing assumption":
Given a hash ...
0
votes
1
answer
66
views
What are the chances of hash collision given large input and small hash?
I have an input of 128 bits (binary, 0s and 1s) and want to hash this input with 32 bit CRC. But I am not sure if collision rate is moderate or too high ?
Is it 2^128/2^32 = 2^98.
And does that ...
1
vote
0
answers
48
views
Finding a full collision within a large array
I apologize for the vagueness of the title, but this question is quite difficult for me to describe.
For that reason, I'm unable to directly convey my problem.
In an effort to circumvent this, I've ...
0
votes
1
answer
463
views
hash-tables - Expected-time for an unsuccessful search
The following question is from MIT-OCW 6.006, Spring-2008, Problem-Set 2, Q-3.c.
Suppose you have a hash table where the load-factor $\alpha$ is related to the number $n$ of elements in the table by ...
1
vote
0
answers
35
views
Average-case retrieval time
The book CLRS claims these statements before introducing the topic of universal hashing:
If a malicious adversary chooses the keys to be hashed by some fixed hash function,
then the adversary can ...
2
votes
1
answer
256
views
Quadratic probing variant scheme
Suppose that we are given a key $k$ to search for in a hash table with positions $0, 1, \dots , m-1$, and suppose that we have a hash function $h$ mapping the key space into the set $\{0, 1, \dots , m-...