Beispiel #1
0
        public static string GetPaymentInfoMd5Hash(string merchantId, string publicAccountId, string nonce, string description, string transactionId, int totalFee, string userIp, string notifyUrl, string tradeType, string openid, string key)
        {
            var concatenationString =
                $"appid={publicAccountId}&body={description}&mch_id={merchantId}&nonce_str={nonce}&notify_url={notifyUrl}&openid={openid}&out_trade_no={transactionId}&spbill_create_ip={userIp}&total_fee={totalFee}&trade_type={tradeType}&key={key}";

            return(Md5Hash.Hash(concatenationString).ToUpper());
        }
Beispiel #2
0
        public static string GetMd5Hash(string merchantId, string nonce, string paymentNumber, string appId, string userOpenId, string checkName, int paymentAmount, string paymentDescription, string requestIpAddress, string key)
        {
            var concatenationString =
                $"amount={paymentAmount}&check_name={checkName}&desc={paymentDescription}&mch_appid={appId}&mchid={merchantId}&nonce_str={nonce}&openid={userOpenId}&partner_trade_no={paymentNumber}&spbill_create_ip={requestIpAddress}&key={key}";

            return(Md5Hash.Hash(concatenationString).ToUpper());
        }
Beispiel #3
0
        public static string GetMd5Hash(string appId, string merchantId, string nonce, string body, string transactionId, int totalFeeInPennies, string ip, string notifyUrl, string tradeType, string openId, string key)
        {
            var concatenationString =
                $"appid={appId}&body={body}&mch_id={merchantId}&nonce_str={nonce}&notify_url={notifyUrl}&openid={openId}&out_trade_no={transactionId}&spbill_create_ip={ip}&total_fee={totalFeeInPennies}&trade_type={tradeType}&key={key}";

            return(Md5Hash.Hash(concatenationString).ToUpper());
        }
Beispiel #4
0
        public static string GetMd5Hash(string merchantId, string nonce, string signType, string key)
        {
            var concatenationString =
                $"mch_id={merchantId}&nonce_str={nonce}&sign_type={signType}&key={key}";

            return(Md5Hash.Hash(concatenationString).ToUpper());
        }
Beispiel #5
0
        public static string GetMd5Hash(string merchantId, string nonce, string paymentNumber, string encryptedCardNumber, string encryptedRecipientName, string bankCode, int paymentAmount, string paymentDescription, string key)
        {
            var concatenationString =
                $"amount={paymentAmount}&bank_code={bankCode}&desc={paymentDescription}&enc_bank_no={encryptedCardNumber}&enc_true_name={encryptedRecipientName}&mch_id={merchantId}&nonce_str={nonce}&partner_trade_no={paymentNumber}&key={key}";

            return(Md5Hash.Hash(concatenationString).ToUpper());
        }
Beispiel #6
0
        public static string GetMd5Hash(string appId, string merchantId, string nonce, string transactionId, string refundId, string totalFeeInPennies, string refundFeeInPennies, string key)
        {
            var concatenationString =
                $"appid={appId}&mch_id={merchantId}&nonce_str={nonce}&op_user_id={merchantId}&out_trade_no={transactionId}&out_refund_no={refundId}&refund_fee={refundFeeInPennies}&total_fee={totalFeeInPennies}&key={key}";

            return(Md5Hash.Hash(concatenationString).ToUpper());
        }
Beispiel #7
0
        public static string GetPaymentSignMd5Hash(string appId, string timeStamp, string nonce, string package, string signType, string key)
        {
            var concatenationString =
                $"appId={appId}&nonceStr={nonce}&package=prepay_id={package}&signType={signType}&timeStamp={timeStamp}&key={key}";

            return(Md5Hash.Hash(concatenationString).ToUpper());
        }
Beispiel #8
0
        public static string GetMd5Hash(string appId, string merchantId, string nonce, string transactionId, string key)
        {
            var concatenationString =
                $"appid={appId}&mch_id={merchantId}&nonce_str={nonce}&out_trade_no={transactionId}&key={key}";

            return(Md5Hash.Hash(concatenationString).ToUpper());
        }
        public byte[] Hash(HashType type, byte[] input)
        {
            switch (type)
            {
            case HashType.Md5Hash:
                Md5Hash md5 = new Md5Hash();
                return(md5.Hash(input));

            case HashType.Sha1Hash:
                Sha1Hash sha1 = new Sha1Hash();
                return(sha1.Hash(input));

            case HashType.Sha2Hash:
                Sha2Hash sha2 = new Sha2Hash();
                return(sha2.Hash(input));

            case HashType.Sha3Hash:
                Sha3Hash sha3 = new Sha3Hash();
                return(sha3.Hash(input));

            case HashType.Sha5Hash:
                Sha5Hash sha5 = new Sha5Hash();
                return(sha5.Hash(input));

            default:
                return(null);
            }
        }
Beispiel #10
0
        // hashing overloads for different inputs
        // string input, byte input, with and without password
        // needs to return byte or string depending on input
        // if string input => string output
        // if byte input => byte output
        public string Hash(HashType type, string input)
        {
            switch (type)
            {
            case HashType.Md5Hash:
                Md5Hash md5 = new Md5Hash();
                return(md5.Hash(input));

            case HashType.Sha1Hash:
                Sha1Hash sha1 = new Sha1Hash();
                return(sha1.Hash(input));

            case HashType.Sha2Hash:
                Sha2Hash sha2 = new Sha2Hash();
                return(sha2.Hash(input));

            case HashType.Sha3Hash:
                Sha3Hash sha3 = new Sha3Hash();
                return(sha3.Hash(input));

            case HashType.Sha5Hash:
                Sha5Hash sha5 = new Sha5Hash();
                return(sha5.Hash(input));

            default:
                return("Cannot hash with this input");
            }
        }