Ejemplo n.º 1
0
        /// <summary>
        /// 进行数字签名
        /// </summary>
        /// <param name="Data"></param>
        /// <returns></returns>
        public static string SiginData(string Data, string PrivateKey)
        {
            string         m_strHashbyteSignature      = "";
            string         m_strEncryptedSignatureData = "";
            RSAEncryptBase RC = new RSAEncryptBase();

            if (RC.GetHash(Data, ref m_strHashbyteSignature) == false)
            {
                throw new Exception("输入数据有误");
            }
            if (RC.SignatureFormatter(PrivateKey, m_strHashbyteSignature, ref m_strEncryptedSignatureData) == false)
            {
                throw new Exception("RSA数字签名错误!");
            }
            return(m_strEncryptedSignatureData);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// 数字签名验证
        /// </summary>
        /// <param name="Data"></param>
        /// <param name="EncryptedSignatureData"></param>
        /// <returns></returns>
        public static bool SiginCheck(string Data, string EncryptedSignatureData, string PublicKey)
        {
            string         m_strHashbyteDeformatter = "";
            RSAEncryptBase RC = new RSAEncryptBase();

            if (RC.GetHash(Data, ref m_strHashbyteDeformatter) == false)
            {
                throw new Exception("输入数据有误");
            }

            if (RC.SignatureDeformatter(PublicKey, m_strHashbyteDeformatter, EncryptedSignatureData) == false)
            {
                return(false);
            }
            else
            {
                return(true);
            }
        }
Ejemplo n.º 3
0
        public static string DecryptString(string encryptString, string privateKey)
        {
            RSAEncryptBase RC = new RSAEncryptBase();

            return(RC.RSADecrypt(privateKey, encryptString));
        }
Ejemplo n.º 4
0
        public static string EncryptString(string source, string publicKey)
        {
            RSAEncryptBase RC = new RSAEncryptBase();

            return(RC.RSAEncrypt(publicKey, source));
        }