Ejemplo n.º 1
0
        /// <summary>
        /// 验证签名
        /// </summary>
        /// <param name="xmlPublicKey">公钥</param>
        /// <param name="rawData">数据</param>
        /// <param name="signature">签名串</param>
        /// <returns></returns>
        public static bool VerifyData(string xmlPublicKey, string rawData, string signature)
        {
            string hashData = MD5Hash.GetHashString(rawData);

            return(RSACrypto.SignatureDeformatter(xmlPublicKey, hashData, signature));
        }
Ejemplo n.º 2
0
 /// <summary>
 /// 签名验证
 /// </summary>
 /// <param name="xmlPublicKey"></param>
 /// <param name="hashDeformatterString"></param>
 /// <param name="deformatterDataString"></param>
 /// <returns></returns>
 public static bool SignatureDeformatter(string xmlPublicKey, string hashDeformatterString, string deformatterDataString)
 {
     byte[] hashbyteDeformatter = Convert.FromBase64String(hashDeformatterString);
     return(RSACrypto.SignatureDeformatter(xmlPublicKey, hashbyteDeformatter, deformatterDataString));
 }
Ejemplo n.º 3
0
 /// <summary>
 /// 签名
 /// </summary>
 /// <param name="xmlPrivateKey"></param>
 /// <param name="hashSignatureString"></param>
 /// <returns></returns>
 public static string SignatureStringFormatter(string xmlPrivateKey, string hashSignatureString)
 {
     byte[] encryptedSignatureData = RSACrypto.SignatureFormatter(xmlPrivateKey, hashSignatureString);
     return(Convert.ToBase64String(encryptedSignatureData));
 }
Ejemplo n.º 4
0
 /// <summary>
 /// 签名
 /// </summary>
 /// <param name="xmlPrivateKey"></param>
 /// <param name="hashSignatureString"></param>
 /// <returns></returns>
 public static byte[] SignatureFormatter(string xmlPrivateKey, string hashSignatureString)
 {
     byte[] hashSignatureBytes = Convert.FromBase64String(hashSignatureString);
     return(RSACrypto.SignatureFormatter(xmlPrivateKey, hashSignatureBytes));
 }
Ejemplo n.º 5
0
 /// <summary>
 /// 验证签名
 /// </summary>
 /// <param name="cleanText"></param>
 /// <param name="signature"></param>
 /// <returns></returns>
 public static bool VerifyData(string cleanText, string signature)
 {
     return(RSACrypto.VerifyData(publicKey, cleanText, signature));
 }
Ejemplo n.º 6
0
 /// <summary>
 /// 签名
 /// </summary>
 /// <param name="cleanText"></param>
 /// <returns></returns>
 public static string SignData(string cleanText)
 {
     return(RSACrypto.SignData(privateKey, cleanText));
 }
Ejemplo n.º 7
0
 /// <summary>
 /// (使用本应用公钥)加密
 /// </summary>
 /// <param name="cleanText">明文</param>
 /// <returns></returns>
 public static string Encrypt(string cleanText)
 {
     return(RSACrypto.Encrypt(cleanText, publicKey));
 }