fix: strip input str
This commit is contained in:
6
rigol_setup_crypter.py
Normal file → Executable file
6
rigol_setup_crypter.py
Normal file → Executable file
@@ -143,10 +143,12 @@ def _des_cbc_crypt(data_bytes, iv_64bits, round_keys, is_encrypt):
|
||||
|
||||
def DataDecryption(strEncryptedDataHex, cpu_serial):
|
||||
"""Decrypts hex string using DES-CBC"""
|
||||
c_hex_str = strEncryptedDataHex.strip()
|
||||
|
||||
try:
|
||||
encrypted_bytes = binascii.unhexlify(strEncryptedDataHex)
|
||||
encrypted_bytes = binascii.unhexlify(c_hex_str)
|
||||
except binascii.Error as e:
|
||||
raise ValueError(f"Invalid hex string provided: {e}")
|
||||
raise ValueError(f"Invalid hex string provided (length {len(c_hex_str)} after stripping): {e}")
|
||||
round_keys, iv_bits = _generate_round_keys(cpu_serial), _generate_iv_bits()
|
||||
decrypted_bytes = _des_cbc_crypt(encrypted_bytes, iv_bits, round_keys, False)
|
||||
try:
|
||||
|
||||
Reference in New Issue
Block a user