def hash_iterative(s, n, k):
'''
Uses Hashing technique mentioned in BLISS pg 19
i/p: string s to be hashed to binary string of length n and weight k
'''
i = 0 # seed which increases till we get Bk^n
while(True):
Bk = [0] * n
I_val = int(hashlib.sha512(s + str(i)).hexdigest(), 16)
count = 0
while(I_val > 0):
pos = I_val % n
I_val /= n
if(Bk[pos] == 0):
Bk[pos] = 1
count += 1
if(count == k):
return np.array(Bk)
i += 1
评论列表
文章目录