Today in docking other people's system, found a very pit problem, SHA1 encryption problem
Others system SHA1 encryption is written in PHP, we are C #.
The same is true for string 123456 encryption, C # 's SHA1 encrypted string is feqncco3yq9h5zugld3czjt4lbs=
The encrypted character of PHP is 7c4a8d09ca3762af61e59520943dc26494f8941b
To solve such a problem, recommend:
<summary>
SHA1 encryption, as with PHP encryption results
</summary>
<param name= "Data" ></param>
<returns></returns>
public static string Sha1sign (String data)
{
byte[] Temp1 = Encoding.UTF8.GetBytes (data);
SHA1CryptoServiceProvider sha = new SHA1CryptoServiceProvider ();
byte[] Temp2 = Sha.computehash (TEMP1);
Sha. Clear (); Look, you can't use this.
String output = Convert.tobase64string (TEMP2);//cannot be converted directly to base64string
var output = bitconverter.tostring (TEMP2);
Output = output. Replace ("-", "");
Output = output. ToLower ();
return output;
}
That's the same result.