Answer the question
In order to leave comments, you need to log in
Error while trying to encrypt python/rsa framework data?
The error itself:
Traceback (most recent call last):
File "C:\Users\root\Documents\Python Projects\Tests\main.py", line 30, in BtnStartEncrypt
self.ReturnEncryptData()
File "C:\Users\root\Documents\Python Projects\Tests\main.py", line 38, in ReturnEncryptData
encrypt_data = rsa.encrypt(data, public_key)
File "C:\Users\root\AppData\Local\Programs\Python\Python38\lib\site-packages\rsa\pkcs1.py", line 171, in encrypt
keylength = common.byte_size(pub_key.n)
AttributeError: 'str' object has no attribute 'n'
def ReturnEncryptData(self):
public_key = self.ui.TextPublicKeyEncrypt.text() # QLineText
data = self.ui.TextEncrypt.toPlainText().encode('utf8') # QEditText
if data and public_key:
encrypt_data = rsa.encrypt(data, public_key) # передаем данные которые ввел пользователь в QEditText и QLineEdit
return self.ui.TextEncrypt.setText(encrypt_data) # возвращаем зашифрованные данные обратно в QEditText
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question