Finally I realized what was the problem it was in displaying the encrypted and decrypted strings when I tried result=QString::fromLocal8Bit((char*)ciphertext);
it worked fine and showed the original text.
solved Wrong Encryption (QT c++ OpenSSL AES 256 CBC)