I have some problem and i can not define the reasons.
I have function to decrypt some info, the return value is a string that converted from binary to string.
public static string Decrypt(string encryptedText, string completeEncodedKey, int keySize)
{
RijndaelManaged aesEncryption = new RijndaelManaged();
aesEncryption.KeySize = keySize;
aesEncryption.BlockSize = 128;
aesEncryption.Mode = CipherMode.CBC;
aesEncryption.Padding = PaddingMode.Zeros;
aesEncryption.IV = Convert.FromBase64String(ASCIIEncoding.UTF8.GetString(Convert.FromBase64String(completeEncodedKey)).Split(',')[0]);
aesEncryption.Key = Convert.FromBase64String(ASCIIEncoding.UTF8.GetString(Convert.FromBase64String(completeEncodedKey)).Split(',')[1]);
ICryptoTransform decrypto = aesEncryption.CreateDecryptor();
byte[] encryptedBytes = Convert.FromBase64CharArray(encryptedText.ToCharArray(), 0, encryptedText.Length);// convert the cipertext to binary
string RESULT = (string)ASCIIEncoding.UTF8.GetString(decrypto.TransformFinalBlock(encryptedBytes, 0, encryptedBytes.Length));//convert the binary to string
return RESULT;
}
The problem appears when i call this function and get the result, and then try to display the result with additional strings, for example by this message box:
String result= function.Decrypt(textToBeDecrypted, key, 128);
MessageBox.Show("This is sample text " + result + " here i want to append another string ");
ONLY APPENDED TEXT (IN THIS EXAMPLE: " here i want to append another string ") IS NOT DISPLAYED
What's wrong with this?