QuasarApp / Qt-Secret

Simple encryption library supporting RSA and AES algorithms.
https://quasarapp.ddns.net:3031/docs/QuasarApp/Qt-Secret/latest/index.html
GNU Lesser General Public License v3.0
246 stars 69 forks source link

Changed data after decode #83

Closed kluszon closed 3 years ago

kluszon commented 3 years ago

I'm encrypting QByteArray which contains some data and archive file content (zip format). After encrypt and decrypt data I can't decompress file data because the file isn't the same. I compared it binary. During encrypting I'm receiving:

When trying to encrypt data, problems arose, the last block contains non-significant zeros. These zeros will be deleted during the decryption process. For encoding and decode data with non-significant zeros use BlockSize::OneByte

I understand this problem and also Block Size::OneByte isn't a solution for me because the file's data can't be changed if we want to decompress it a success.

Is it any way to achieve encryption and decryption without losing data in this case?

EndrII commented 3 years ago

it is very strange that the data has changed, this should not be. you can show the code that encrypts and decrypts your file. And show which constructor was used to create the QRSAEncryption object

kluszon commented 3 years ago

I investigate my code deeply and it isn't a problem in Qt-Secret. It works correctly. I made the mistake of saving the archive data after decoding from QByteArray to file by QFile.

Sorry, for the confusion.

eugene20237 commented 2 years ago

What is the right way to avoid this problem? Non-significant zeros may be present in any byte array, generated as hash like SHA. BlockSize::OneByte is too slow mode. @EndrII