moolb

Bloom filter for python3 with pluggable hasher backend
git clone git://git.defalsify.org/python-moolb.git
Log | Files | Refs | README | LICENSE

commit 41b5b7f80772aeacba4b97d80ca8f5a2dc7f7eaf
parent 922cf06a733ed6bab8e24950024a3e024c2a66da
Author: nolash <dev@holbrook.no>
Date:   Fri, 30 Oct 2020 20:17:45 +0100

Use binary input instead of strings

Diffstat:
Mmoolb/moolb.py | 11+++++++----
1 file changed, 7 insertions(+), 4 deletions(-)

diff --git a/moolb/moolb.py b/moolb/moolb.py @@ -29,9 +29,11 @@ class Bloom: def add(self, b): for i in range(self.rounds): - salt = str(i) - s = salt.encode('utf-8') + #salt = str(i) + #s = salt.encode('utf-8') + s = i.to_bytes(4, byteorder='big') z = self.__hash(b, s) + logg.debug('result {}'.format(z.hex())) r = int.from_bytes(z, byteorder='big') m = r % self.bits bytepos = math.floor(m / 8) @@ -43,8 +45,9 @@ class Bloom: def check(self, b): for i in range(self.rounds): - salt = str(i) - s = salt.encode('utf-8') + #salt = str(i) + #s = salt.encode('utf-8') + s = i.to_bytes(4, byteorder='big') z = self.__hash(b, s) r = int.from_bytes(z, byteorder='big') m = r % self.bits