public static bool VerifyData(string source, string signData, string publicKey, Encoding encoding = null, RSAOutType outType = RSAOutType.Base64, RSAKeyType type = RSAKeyType.Base64) { if (encoding == null) { encoding = Encoding.UTF8; } byte[] sourceBytes = encoding.GetBytes(source); byte[] signBytes; if (outType == RSAOutType.Base64) { signBytes = Convert.FromBase64String(signData); } else { signBytes = Convert.FromBase64String(signData); } return(VerifyData(sourceBytes, signBytes, publicKey, type)); }
public static string SignData(string source, string privateKey, Encoding encoding = null, RSAOutType outType = RSAOutType.Base64) { if (encoding == null) { encoding = Encoding.UTF8; } var result = SignData(encoding.GetBytes(source), privateKey, RSAPrivateKeyFormat.PKCS8); if (outType == RSAOutType.Base64) { return(Convert.ToBase64String(result)); } StringBuilder sb = new StringBuilder(); for (int i = 0; i < result.Length; i++) { sb.Append(result[i].ToString("x2")); } return(sb.ToString()); }