birthday-paradox

Probability of hash collision

血红的双手。 提交于 2021-01-21 11:05:24
问题 I am looking for some precise math on the likelihood of collisions for MD5, SHA1, and SHA256 based on the birthday paradox. I am looking for something like a graph that says "If you have 10^8 keys, this is the probability. If you have 10^13 keys, this is the probability and so on" I have looked at tons of articles but I am having a tough time finding something that gives me this data. (Ideal option for me would be a formula or code that calculates this for any provided hash size) 回答1: Let's

Probability of hash collision

社会主义新天地 提交于 2021-01-21 11:05:23
问题 I am looking for some precise math on the likelihood of collisions for MD5, SHA1, and SHA256 based on the birthday paradox. I am looking for something like a graph that says "If you have 10^8 keys, this is the probability. If you have 10^13 keys, this is the probability and so on" I have looked at tons of articles but I am having a tough time finding something that gives me this data. (Ideal option for me would be a formula or code that calculates this for any provided hash size) 回答1: Let's

Is there a reverse way to find number of people with given 0.5 probability that two people will have same birthday but no using mathematical formula?

孤人 提交于 2020-02-25 06:16:06
问题 I'm doing birthday paradox, and want to know how many people can meet 0.5 probability that two people have same birthday by using python. I have tried no using mathematical formula to find probability with given the number of people by using random and randint in python import random def random_birthdays(): bdays = [] bdays = [random.randint(1, 365) for i in range(23)] bdays.sort() for x in range(len(bdays)): while x < len(bdays)-1: print x if bdays[x] == bdays[x+1]: #print(bdays[x]) return

Why isn't this Random number generation code working?

最后都变了- 提交于 2020-01-14 19:22:07
问题 I'm writing a program for proving the 'Birthday Paradox'. For i = 0 To (pnum - 1) days(i) = rnd(h:=365) Next It generates a random number for every i (days(i)) between 1 and 365, the function is: Private Function rnd(h As Integer) Dim num As Integer Dim rnum As Random rnum = New Random num = rnum.Next(1, h) Return num End Function When I add a breakpoint in the for loop and go through it manually, it works fine, but if I just run the program, it puts the same random number in every slot in

Generalised Birthday Calculation Given Hash Length

这一生的挚爱 提交于 2019-12-11 03:14:50
问题 Let us assume that we are given the following: The length of the hash The chance of obtaining a collision Now, knowing the above, how can we obtain the number of "samples" needed to obtain the given chance percentage? 回答1: When we take the Simplified formula for the birthday paradox we get: probability = k^2/2N So: sqr(probability*2*n) = k Where we know that n = 2^lenghtHash A small test: Hash = 16 bit : N= 65536 probability = 50% = 0.5 sqr(0.5*2*65536) = 256 samples This is not 100% correct

Uniquely identifying URLs with one 64-bit number

一世执手 提交于 2019-12-09 06:28:48
问题 This is basically a math problem, but very programing related: if I have 1 billion strings containing URLs, and I take the first 64 bits of the MD5 hash of each of them, what kind of collision frequency should I expect? How does the answer change if I only have 100 million URLs? It seems to me that collisions will be extremely rare, but these things tend to be confusing. Would I be better off using something other than MD5? Mind you, I'm not looking for security, just a good fast hash

Birthday Paradox: How to programmatically estimate the probability of 3, and N, people sharing a birthday

拜拜、爱过 提交于 2019-12-08 05:14:07
问题 There are extensive resources on the internet discussing the famous Birthday Paradox . It is clear to me how you calculate the probability of two people sharing a birthday i.e. P(same) = 1 - P(different) . However if I ask myself something apparently more simple I stall: firstly, let's say I generate two random birthdays. Getting the same birthday is like tossing a coin. Either the two persons share a birthday (Heads) or they don't share a birthday (Tail). Run this 500 times and the end

Why am I getting dups with random.shuffle in Python?

我是研究僧i 提交于 2019-12-07 09:44:24
问题 For a list of 10 ints, there are 10! possible orders or permutations. Why does random.shuffle give duplicates after only 5000 tries? >>> L = range(10) >>> rL = list() >>> for i in range(5000): ... random.shuffle(L) ... rL.append(L[:]) ... >>> rL = [tuple(e) for e in rL] >>> len(set(rL)) 4997 >>> for i,t in enumerate(rL): ... if rL.count(t) > 1: ... print i,t ... 102 (7, 5, 2, 4, 0, 6, 9, 3, 1, 8) 258 (1, 4, 0, 2, 7, 3, 5, 9, 6, 8) 892 (1, 4, 0, 2, 7, 3, 5, 9, 6, 8) 2878 (7, 5, 2, 4, 0, 6, 9,

Can someone please clarify the Birthday Effect for me?

你离开我真会死。 提交于 2019-12-07 06:22:42
问题 Please help interpret the Birthday effect as described in Wikipedia: A birthday attack works as follows: Pick any message m and compute h(m). Update list L. Check if h(m) is in the list L. if (h(m),m) is already in L, a colliding message pair has been found. else save the pair (h(m),m) in the list L and go back to step 1. From the birthday paradox we know that we can expect to find a matching entry, after performing about 2^(n/2) hash evaluations. Does the above mean 2^(n/2) iterations

Why am I getting dups with random.shuffle in Python?

∥☆過路亽.° 提交于 2019-12-05 14:38:26
For a list of 10 ints, there are 10! possible orders or permutations. Why does random.shuffle give duplicates after only 5000 tries? >>> L = range(10) >>> rL = list() >>> for i in range(5000): ... random.shuffle(L) ... rL.append(L[:]) ... >>> rL = [tuple(e) for e in rL] >>> len(set(rL)) 4997 >>> for i,t in enumerate(rL): ... if rL.count(t) > 1: ... print i,t ... 102 (7, 5, 2, 4, 0, 6, 9, 3, 1, 8) 258 (1, 4, 0, 2, 7, 3, 5, 9, 6, 8) 892 (1, 4, 0, 2, 7, 3, 5, 9, 6, 8) 2878 (7, 5, 2, 4, 0, 6, 9, 3, 1, 8) 4123 (5, 8, 0, 1, 7, 3, 2, 4, 6, 9) 4633 (5, 8, 0, 1, 7, 3, 2, 4, 6, 9) >>> 10*9*8*7*6*5*4*3*2