mirror of
https://github.com/LBRYFoundation/lbry-sdk.git
synced 2025-08-28 07:51:33 +00:00
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):
|
class Distance(object):
|
||||||
"""Calculate the XOR result between two string variables.
|
"""Calculate the XOR result between two string variables.
|
||||||
|
|
||||||
|
@ -6,6 +9,8 @@ class Distance(object):
|
||||||
"""
|
"""
|
||||||
|
|
||||||
def __init__(self, key):
|
def __init__(self, key):
|
||||||
|
if len(key) != constants.key_bits / 8:
|
||||||
|
raise ValueError("invalid key length: %i", len(key))
|
||||||
self.key = key
|
self.key = key
|
||||||
self.val_key_one = long(key.encode('hex'), 16)
|
self.val_key_one = long(key.encode('hex'), 16)
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue