예제 #1
0
 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));
 }
예제 #2
0
 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));
 }