verify key size in Distance

This commit is contained in:
Jack Robison 2018-05-29 10:59:46 -04:00
parent 0d23c68797
commit 73e813f9ec
No known key found for this signature in database
GPG key ID: DF25C68FE0239BB2

View file

@ -1,3 +1,6 @@
from lbrynet.dht import constants
class Distance(object):
"""Calculate the XOR result between two string variables.
@ -6,6 +9,8 @@ class Distance(object):
"""
def __init__(self, key):
if len(key) != constants.key_bits / 8:
raise ValueError("invalid key length: %i", len(key))
self.key = key
self.val_key_one = long(key.encode('hex'), 16)