forked from LBRYCommunity/lbry-sdk
faster is_valid_hashcharacter
This commit is contained in:
parent
45404b6ad4
commit
0c93090d2c
1 changed files with 5 additions and 4 deletions
|
@ -18,13 +18,13 @@ from lbrynet.blob.writer import HashBlobWriter
|
|||
log = logging.getLogger(__name__)
|
||||
|
||||
|
||||
def is_valid_hashcharacter(char: str) -> bool:
|
||||
return char in "0123456789abcdef"
|
||||
|
||||
|
||||
_hexmatch = re.compile("^[a-f,0-9]+$")
|
||||
|
||||
|
||||
def is_valid_hashcharacter(char: str) -> bool:
|
||||
return len(char) == 1 and _hexmatch.match(char)
|
||||
|
||||
|
||||
def is_valid_blobhash(blobhash: str) -> bool:
|
||||
"""Checks whether the blobhash is the correct length and contains only
|
||||
valid characters (0-9, a-f)
|
||||
|
@ -35,6 +35,7 @@ def is_valid_blobhash(blobhash: str) -> bool:
|
|||
"""
|
||||
return len(blobhash) == blobhash_length and _hexmatch.match(blobhash)
|
||||
|
||||
|
||||
def encrypt_blob_bytes(key: bytes, iv: bytes, unencrypted: bytes) -> typing.Tuple[bytes, str]:
|
||||
cipher = Cipher(AES(key), modes.CBC(iv), backend=backend)
|
||||
padder = PKCS7(AES.block_size).padder()
|
||||
|
|
Loading…
Reference in a new issue