The C# program always fails the verification when sending the RSA-encrypted password to the backend. I use wireshark to capture packets and find that the + signs in the password sent by POST have become spaces. In order to send data correctly, URL transcoding protocol is used for transcoding.
There are two methods for URL transcoding
The first is to use HttpUtility.UrlEncode(), the namespace is System.Web
But I use The C# version no longer supports this writing method
The second is to use WebUtility.UrlEncode(), the namespace is System.Net
The C# version I use is normally used, and it is recommended to use this Function
//If you need POST data
if (!(parameters == null || parameters.Count = = 0))
{
StringBuilder buffer = new StringBuilder();
int i = 0;
foreach (string key in parameters.Keys)
{
if (i> 0)
{
//Transcoding post content with special characters span>
buffer.AppendFormat("&{0}={1}< span style="color: #800000;">", key, WebUtility.UrlEncode(parameters[key]));
}
else
{
//Transcoding post content with special characters span>
buffer.AppendFormat("{0}={1}", key, WebUtility.UrlEncode(parameters[key]));
}
i++;
}
byte[] data = charset.GetBytes(buffer.ToString() );
using (Stream stream = request.GetRequestStream())
{
stream.Write(data, 0, data.Length);
}
}
//If you need POST data
if (!(parameters == null || parameters.Count = = 0))
{
StringBuilder buffer = new StringBuilder();
int i = 0;
foreach (string key in parameters.Keys)
{
if (i> 0)
{
//Transcoding post content with special characters span>
buffer.AppendFormat("&{0}={1}< span style="color: #800000;">", key, WebUtility.UrlEncode(parameters[key]));
}
else
{
//Transcoding post content with special characters span>
buffer.AppendFormat("{0}={1}", key, WebUtility.UrlEncode(parameters[key]));
}
i++;
}
byte[] data = charset.GetBytes(buffer.ToString() );
using (Stream stream = request.GetRequestStream())
{
stream.Write(data, 0, data.Length);
}
}