moolb

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

commit c51dc47f80f0a6baa285f689b729606cd40b9f8f
parent bbe443f58ca5411d20b9aa436542f91c457112e1
Author: nolash <dev@holbrook.no>
Date:   Thu, 29 Oct 2020 20:48:28 +0100

Initial commit, add v to filer

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

diff --git a/main.py b/main.py @@ -18,13 +18,13 @@ class BloomFilter: self.filter = numpy.zeros(self.bytes, dtype=numpy.uint8) - def add(self, s): + def add(self, b): for i in range(self.rounds): salt = str(i) salt_str = salt.encode('utf-8') - logg.debug('hashing {} {}'.format(s, salt)) + logg.debug('hashing {} {}'.format(b.hex(), salt)) h = hashlib.sha256() - h.update(s.encode('utf-8')) + h.update(b) h.update(salt_str) z = h.digest() r = int.from_bytes(z, byteorder='big') @@ -36,5 +36,8 @@ class BloomFilter: return m + def check(self, s): + + f = BloomFilter(8192 * 8, 3) -f.add('1024') +f.add(b'1024')