【发布时间】:2013-04-29 19:24:17
【问题描述】:
我有一些问题,我无法定义原因。
我有解密一些信息的功能,返回值是一个从二进制转换为字符串的字符串。
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;
}
当我调用此函数并获取结果时出现问题,然后尝试使用其他字符串显示结果,例如通过此消息框:
String result= function.Decrypt(textToBeDecrypted, key, 128);
MessageBox.Show("This is sample text " + result + " here i want to append another string ");
仅附加文本(在此示例中:“这里我想附加另一个字符串”)不显示
这是怎么回事?
【问题讨论】:
-
使用调试器。单步执行
Decrypt。沿途检查值。找到问题。 -
result 值显示得很好,并按我的预期返回。但是当我附加另一个文本时,不会显示这个新文本。
-
所以你的意思是
here i want to append another string没有显示? -
正是我的意思