# Probability of collision when we use a particular part of sha 256 hashed value

So I was supposed to use hash some co-ordinates and I was supposed to use k 3-wise independent hash functions in order for the mathematical explanations behind that algorithm to be hold. But after using k 3 wise independent hash functions, I got kinda bad accuracy(I used tabulation hashing which I myself wrote for this. Then I decided to use some cryptographic hash function for collision resistance and ended up using sha256 in this way

• As I have to generate k different hash functions for my purpose, I generated k different seeds and wrote this snippet -
hex_num = hashlib.sha256((str(self.seed[i])+str(d)).encode('utf-8')).hexdigest()
int_hex = int(hex_num[:5],16)
index = int_hex % self.width


where I want to get the hashed values in the range of 0 to self.width-1. Now I had a few questions-

• Do you really need hash instead of use Encryption so that no two different plaintexts can map to the same ciphertext? The collision probability is given by the birthday-paradox. For two-item, it is almost zero. What is your total items, so that one can provide an almost exact number? If the result of the hash is not fitted then rejection should be applied inorder to eliminate the bias. Aug 10, 2020 at 20:50
• Also, what is self.width? Aug 10, 2020 at 20:57
• Aug 10, 2020 at 21:08
• @kelalaka self.width is originally the width of a table, but you can actually assume that it is the range of output. Aug 10, 2020 at 23:52
• You can edit your question to clarify more. As it stands the: Birthday problem for cryptographic hashing, 101 answers your question. Just plug the numbers. Can we call it dupe? Aug 11, 2020 at 9:32