Skip to content

Commit

Permalink
fixes hash result not being distributed evenly over the bitarray
Browse files Browse the repository at this point in the history
  • Loading branch information
Berkay Dincer committed Nov 14, 2019
1 parent c1278a6 commit b33ccb4
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 15 deletions.
6 changes: 3 additions & 3 deletions bloomfpy/bloompy.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,15 +38,15 @@ def __len__(self):
return self.count

def _hash_value(self, key, salt):
hashfunc = hashlib.sha1()
hashfunc = hashlib.sha256()
if isinstance(key, str):
key = key.encode('utf-8')
else:
key = str(key).encode('utf-8')

hashfunc.update(key + salt.bytes)
for idx in hashfunc.digest():
return idx % self.num_bits
uint = int.from_bytes(hashfunc.digest(), "little")
return uint % self.num_bits

def add(self, key):
if self.count > self.capacity:
Expand Down
12 changes: 0 additions & 12 deletions bloomfpy/main.py

This file was deleted.

0 comments on commit b33ccb4

Please sign in to comment.