Я реализовал шифрование / дешифрование 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êÁ $].я думаю, что есть некоторые специальные символы, которые вызов веб-службы не позволяет.
Как мы можем справиться с этим?
----------------------- Зашифрованный / дешифрованный процесс ---------------------
//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);