forked from LBRYCommunity/lbry-sdk
verify key size in Distance
This commit is contained in:
parent
0d23c68797
commit
73e813f9ec
1 changed files with 5 additions and 0 deletions
|
@ -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)
|
||||
|
||||
|
|
Loading…
Reference in a new issue