Hello,
I am facing a problem using the AES decryption that I got from link
My function exits and doesn't continue the algorithm after the execution of the following line of codeI have surfed the web, and I've found several issues with same problem without any solution.Code:bufDecryptor->ProcessFinalL(plainTextPtr,cipherTextPtr);
So can anyone help me with this issue ?
Kindly find below the function I am using for decryption.
Note that there is something so weird about it; Sometimes I am able to decrypt some encrypted data with the same algorithm,and sometimes it fails for another encrypted data.Code:QString MainWindow::decryptData(QString dataToDecrypt,QString keyOfDecryption) { TPtrC16 textPtr1(reinterpret_cast<const TUint16*>(keyOfDecryption.utf16())); HBufC8 *pHeap81 = HBufC8::NewMaxLC(textPtr1.Length()); pHeap81->Des().Copy(textPtr1); TPtr8 aKey = pHeap81->Des(); TPtr8 aIv = pHeap81->Des(); QString enc(QByteArray::fromBase64(dataToDecrypt.toAscii())); RFs fsSession; User::LeaveIfError(fsSession.Connect()); TPtrC16 textPtr(reinterpret_cast<const TUint16*>(enc.utf16())); HBufC8 *pHeap8 = HBufC8::NewMaxLC(textPtr.Length()); pHeap8->Des().Copy(textPtr); TPtr8 plainTextPtr = pHeap8->Des(); CAESDecryptor* method = CAESDecryptor::NewL(aKey); CModeCBCDecryptor* mode = CModeCBCDecryptor::NewL(method, aIv); CPadding* padding = CPaddingPKCS7::NewL(method->BlockSize()); CBufferedDecryptor* bufDecryptor = CBufferedDecryptor::NewL(mode, padding); HBufC8* cipherText = HBufC8::NewL(bufDecryptor->MaxFinalOutputLength(plainTextPtr.Size())); TPtr8 cipherTextPtr = cipherText->Des(); bufDecryptor->ProcessFinalL(plainTextPtr,cipherTextPtr); QString result3; result3=QString::fromAscii((const char *)cipherText->Ptr(), cipherText->Length()); CleanupStack::PopAndDestroy(); CleanupStack::PopAndDestroy(); return result3; }
Best Regards,
elippo

Reply With Quote


