예제 #1
0
class Hashedbitset():

    def __init__(self, size):
        self._value = Bitset(size)
        self._size = size
        self._hasher = Hasher()

    def Add(self, item):
        self._value.Add(self._hasher.hash(item, 1)[0])

    def Size(self):
        return self._value.Size()

    def Contains(self, item):
        n = self._hasher.hash(item, 1)[0]
        return self._value.Contains(n)
예제 #2
0
class Bloomfilter():
    def __init__(self, size, keys):
        self._value = Bitset(size)
        self._size = size
        self._keys = keys
        self._hasher = Hasher()

    def Add(self, item):
        [self._value.Add(i) for i in self._hasher.hash(item, self._keys)]

    def Size(self):
        return self._value.Size()

    def Contains(self, item):
        n = self._hasher.hash(item, self._keys)
        for i in n:
            if not self._value.Contains(i):
                return False
        return True
예제 #3
0
from hasher import Hasher

hasher = Hasher('')

print(hasher.hash('my name is jack'))
예제 #4
0
파일: crypto.py 프로젝트: atduskgreg/wire
def _derive_key(key, salt=get_random_bytes(32)):
    h = Hasher(10)
    return h.hash(key, salt)[-32:], salt