Pycryptodome: cipher_rsa.decrypt(byte_string, sentinel) возвращает значение sentinel каждый раз

Ниже приведен мой код

    from base64 import b64encode, b64decode
    from pathlib import Path
    from Crypto.Cipher import AES, PKCS1_v1_5
    from Crypto.PublicKey import RSA
    from Crypto.Cipher import PKCS1_v1_5

def decrypt(base64_ciphertext):
    recipient_key = RSA.import_key(open(f"key.key).read())

    ciphertext = b64decode(base64_ciphertext)
    print(ciphertext, 'ciphertext is here')
    cipher_rsa = PKCS1_v1_5.new(recipient_key)
    print(cipher_rsa, 'cipher_rsa is here')
    data = cipher_rsa.decrypt(ast.literal_eval(str(ciphertext)), 'Error occured')
    print(data, 'data is here')
    return data

Возвращаемое значение Error occured каждый раз, когда я запускаю эту функцию. Я прочитал все ссылки, которые смог найти, но не могу понять, в чем дело. Пожалуйста, помогите. Есть ли способ регистрировать фактическую ошибку вместо значения sentinel

Вернуться на верх