public static string sign(string content, string privateKey, string input_charset) { System.Text.Encoding encoding = System.Text.Encoding.GetEncoding(input_charset); byte[] bytes = encoding.GetBytes(content); System.Security.Cryptography.RSACryptoServiceProvider rSACryptoServiceProvider = RSAFromPkcs8.DecodePemPrivateKey(privateKey); System.Security.Cryptography.SHA1 halg = new System.Security.Cryptography.SHA1CryptoServiceProvider(); byte[] inArray = rSACryptoServiceProvider.SignData(bytes, halg); return(System.Convert.ToBase64String(inArray)); }
private static byte[] decrypt(byte[] data, string privateKey, string input_charset) { System.Security.Cryptography.RSACryptoServiceProvider rSACryptoServiceProvider = RSAFromPkcs8.DecodePemPrivateKey(privateKey); new System.Security.Cryptography.SHA1CryptoServiceProvider(); return(rSACryptoServiceProvider.Decrypt(data, false)); }