Exemple #1
0
        public static string CreateRequestMySign(SortedDictionary <string, string> paramReqs, string secret, string _input_charset = "utf-8")
        {
            //过滤签名参数数组
            var sPara = SignCore.FilterPara(paramReqs);

            //“参数=参数值”的模式用“&”字符拼接
            string temp = SignCore.CreateLinkString(sPara);

            //获得签名结果
            string mysign = SignCore.CreateSign(temp, secret);

            return(mysign);
        }
Exemple #2
0
        /// <summary>
        /// 验证签名是否正确
        /// </summary>
        /// <param name="prestr">需要签名的字符串</param>
        /// <param name="sign">签名结果</param>
        /// <param name="key">密钥</param>
        /// <param name="_input_charset">编码格式</param>
        /// <returns>验证结果</returns>
        public bool VerifySign(string prestr, string sign, string secret, string _input_charset = "utf-8")
        {
            string mysign = SignCore.CreateSign(prestr, secret, _input_charset);

            if (mysign == sign)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
Exemple #3
0
        /// <summary>
        /// 对请求参数进行签名
        /// </summary>
        /// <param name="paramReqs"></param>
        /// <param name="secret"></param>
        /// <returns></returns>
        public string SignRequest(SortedDictionary <string, string> paramReqs, string secret)
        {
            //待签名请求参数数组
            Dictionary <string, string> sPara = new Dictionary <string, string>();

            //过滤签名参数数组
            sPara = SignCore.FilterPara(paramReqs);

            //“参数=参数值”的模式用“&”字符拼接
            string temp = SignCore.CreateLinkString(sPara);

            //获得签名结果
            string mysign = SignCore.CreateSign(temp, secret);

            return(mysign);
        }
Exemple #4
0
        /// <summary>
        /// 验证sign是否正确
        /// </summary>
        /// <param name="paramReqs">请求的参数</param>
        /// <param name="sign">签名结果</param>
        /// <param name="secret">密钥</param>
        /// <param name="_input_charset">编码格式</param>
        /// <returns></returns>
        public bool VerifySign(SortedDictionary <string, string> paramReqs, string urlSign, string secret, string _input_charset = "utf-8")
        {
            //过滤签名参数数组
            var sPara = SignCore.FilterPara(paramReqs);

            //“参数=参数值”的模式用“&”字符拼接
            string temp = SignCore.CreateLinkString(sPara);

            //获得签名结果
            string mysign = SignCore.CreateSign(temp, secret, _input_charset);

            if (mysign == urlSign)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }