fix: strip input str

This commit is contained in:
2025-04-14 17:31:49 +06:00
parent ad4d406a2d
commit d984ed8423
3 changed files with 1590 additions and 2 deletions

6
rigol_setup_crypter.py Normal file → Executable file
View 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: