update() public method

public update ( byte data, uint length ) : void
data byte
length uint
return void
Esempio n. 1
0
    public static string CreateHmac(string aValue)
    {
        string aKey = CustomerConfig.merchantKey;
        byte[] k_ipad = new byte[64];
        byte[] k_opad = new byte[64];
        byte[] keyb;
        byte[] Value;
        keyb = Encoding.UTF8.GetBytes(aKey);
        Value = Encoding.UTF8.GetBytes(aValue);

        for (int i = keyb.Length; i < 64; i++)
            k_ipad[i] = 54;

        for (int i = keyb.Length; i < 64; i++)
            k_opad[i] = 92;

        for (int i = 0; i < keyb.Length; i++)
        {
            k_ipad[i] = (byte)(keyb[i] ^ 0x36);
            k_opad[i] = (byte)(keyb[i] ^ 0x5c);
        }

        HmacMD5 md = new HmacMD5();

        md.update(k_ipad, (uint)k_ipad.Length);
        md.update(Value, (uint)Value.Length);
        byte[] dg = md.finalize();
        md.init();
        md.update(k_opad, (uint)k_opad.Length);
        md.update(dg, 16);
        dg = md.finalize();

        return toHex(dg);
    }
Esempio n. 2
0
        public static string HmacSign(this string aValue, string aKey)
        {
            var kIpad = new byte[64];
            var kOpad = new byte[64];
            var keyb  = Encoding.UTF8.GetBytes(aKey);
            var value = Encoding.UTF8.GetBytes(aValue);

            for (var i = keyb.Length; i < 64; i++)
            {
                kIpad[i] = 54;
            }

            for (var i = keyb.Length; i < 64; i++)
            {
                kOpad[i] = 92;
            }

            for (var i = 0; i < keyb.Length; i++)
            {
                kIpad[i] = (byte)(keyb[i] ^ 0x36);
                kOpad[i] = (byte)(keyb[i] ^ 0x5c);
            }

            var md = new HmacMD5();

            md.update(kIpad, (uint)kIpad.Length);
            md.update(value, (uint)value.Length);
            var dg = md.finalize();

            md.init();
            md.update(kOpad, (uint)kOpad.Length);
            md.update(dg, 16);
            dg = md.finalize();
            if (dg == null)
            {
                return(null);
            }
            var output = new StringBuilder(dg.Length * 2);

            for (var i = 0; i < dg.Length; i++)
            {
                var current = dg[i] & 0xff;
                if (current < 16)
                {
                    output.Append("0");
                }
                output.Append(current.ToString("x"));
            }
            return(output.ToString());
        }
Esempio n. 3
0
    public static string CreateHmac(string aValue)
    {
        string aKey = CustomerConfig.merchantKey;

        byte[] k_ipad = new byte[64];
        byte[] k_opad = new byte[64];
        byte[] keyb;
        byte[] Value;
        keyb  = Encoding.UTF8.GetBytes(aKey);
        Value = Encoding.UTF8.GetBytes(aValue);

        for (int i = keyb.Length; i < 64; i++)
        {
            k_ipad[i] = 54;
        }

        for (int i = keyb.Length; i < 64; i++)
        {
            k_opad[i] = 92;
        }

        for (int i = 0; i < keyb.Length; i++)
        {
            k_ipad[i] = (byte)(keyb[i] ^ 0x36);
            k_opad[i] = (byte)(keyb[i] ^ 0x5c);
        }

        HmacMD5 md = new HmacMD5();

        md.update(k_ipad, (uint)k_ipad.Length);
        md.update(Value, (uint)Value.Length);
        byte[] dg = md.finalize();
        md.init();
        md.update(k_opad, (uint)k_opad.Length);
        md.update(dg, 16);
        dg = md.finalize();

        return(toHex(dg));
    }
Esempio n. 4
0
            /// <summary>
            /// 生成易宝签名
            /// </summary>
            /// <param name="signString">散列字符串</param>
            /// <param name="key">商户密钥</param>
            public static string HmacSign(string signString, string key)
            {
                byte[] k_ipad = new byte[64];
                byte[] k_opad = new byte[64];
                byte[] keyb;
                byte[] Value;
                keyb  = Encoding.UTF8.GetBytes(key);
                Value = Encoding.UTF8.GetBytes(signString);

                for (int i = keyb.Length; i < 64; i++)
                {
                    k_ipad[i] = 54;
                }

                for (int i = keyb.Length; i < 64; i++)
                {
                    k_opad[i] = 92;
                }

                for (int i = 0; i < keyb.Length; i++)
                {
                    k_ipad[i] = (byte)(keyb[i] ^ 0x36);
                    k_opad[i] = (byte)(keyb[i] ^ 0x5c);
                }

                HmacMD5 md = new HmacMD5();

                md.update(k_ipad, (uint)k_ipad.Length);
                md.update(Value, (uint)Value.Length);
                byte[] dg = md.finalize();
                md.init();
                md.update(k_opad, (uint)k_opad.Length);
                md.update(dg, 16);
                dg = md.finalize();

                return(toHex(dg));
            }
Esempio n. 5
0
            /// <summary>
            /// �����ױ�ǩ��
            /// </summary>
            /// <param name="signString">ɢ���ַ���</param>
            /// <param name="key">�̻���Կ</param>
            public static string HmacSign(string signString, string key)
            {
                byte[] k_ipad = new byte[64];
                byte[] k_opad = new byte[64];
                byte[] keyb;
                byte[] Value;
                keyb = Encoding.UTF8.GetBytes(key);
                Value = Encoding.UTF8.GetBytes(signString);

                for (int i = keyb.Length; i < 64; i++)
                    k_ipad[i] = 54;

                for (int i = keyb.Length; i < 64; i++)
                    k_opad[i] = 92;

                for (int i = 0; i < keyb.Length; i++)
                {
                    k_ipad[i] = (byte)(keyb[i] ^ 0x36);
                    k_opad[i] = (byte)(keyb[i] ^ 0x5c);
                }

                HmacMD5 md = new HmacMD5();
                md.update(k_ipad, (uint)k_ipad.Length);
                md.update(Value, (uint)Value.Length);
                byte[] dg = md.finalize();
                md.init();
                md.update(k_opad, (uint)k_opad.Length);
                md.update(dg, 16);
                dg = md.finalize();

                return toHex(dg);
            }