【发布时间】:2011-04-04 07:49:50
【问题描述】:
我在我的应用程序中实现了 RC4 加密/解密,如下所示。 在行尾出现异常。
string sFNToBase64String = Convert.ToBase64String(Encoding.ASCII.GetBytes("Malhotra"));
string sEnFirstName = CommonFunction.RC4EncryptDecrypt(sKey, sFNToBase64String);
//calling webservice
localhost.LoginRequest objRQ = new localhost.LoginRequest();
string sIsValidate = objRQ.ValidateRequest(sEnFirstName); //Exception coming on this line
异常来了
//Exception coming
The request failed with HTTP status 400: Bad Request.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.Net.WebException: The request failed with HTTP status 400: Bad Request.
我们如何解决它。
------------更新-------
实际上问题仅在于“Malhotra”的加密文本[加密文本:CX±£þÕlêÁ$]。 我认为有一些特殊字符是 Web 服务调用不允许的。
我们如何处理这个问题?
---------------------加密/解密过程-- ----
//Encrypte
string sEnLastName = CommonFunction.RC4EncryptDecrypt(sKey, "Malhotra");
//Encode
string sLNToBase64String = Convert.ToBase64String(Encoding.ASCII.GetBytes(sEnLastName));
//Decode
string sDecodeLastName = Encoding.ASCII.GetString(Convert.FromBase64String(sLNToBase64String));
//Decrypte
string sDeLastName = CommonFunction.RC4EncryptDecrypt(sKey, sDecodeLastName);
【问题讨论】:
-
异常发生在哪一行?
-
字符串 sIsValidate = objRQ.ValidateRequest(sEnFirstName);
-
请查看更新后的问题。
标签: asp.net encryption