Exemple #1
0
        //出金数据加密示例
        static void withdraw(FexpayUtils util, string key, string smac)
        {
            //编辑出金数据
            WithdrawDataStructure data = new WithdrawDataStructure();

            data.realName  = Uri.EscapeDataString("实名02");
            data.amount    = "0.48";
            data.coinId    = "1";
            data.orderId   = "2018071318275278925";
            data.idCard    = "2222222222";
            data.notifyUrl = "https://www.domain.com/notify/withdraw/callback";
            data.returnUrl = "https://www.domain.com/return/withdraw/callback";
            data.sendTime  = "2018-07-13 18:27:52";

            DataContractJsonSerializer js = new DataContractJsonSerializer(typeof(WithdrawDataStructure));
            MemoryStream msObj            = new MemoryStream();

            js.WriteObject(msObj, data);
            msObj.Position = 0;
            StreamReader sr   = new StreamReader(msObj, Encoding.UTF8);
            string       json = sr.ReadToEnd().Replace("\\", "");

            sr.Close();
            msObj.Close();

            Console.WriteLine("\r\n=========出金===========");
            string sign = util.md5(json + smac).ToUpper();

            Console.WriteLine("json + smac:" + json + smac);
            Console.WriteLine("sign:" + sign);

            //编辑出金密文
            WithdrawCipherTextStructure cipherText = new WithdrawCipherTextStructure();

            cipherText.data = data;
            cipherText.sign = sign;

            DataContractJsonSerializer cipherjs = new DataContractJsonSerializer(typeof(WithdrawCipherTextStructure));
            MemoryStream cipherObj = new MemoryStream();

            cipherjs.WriteObject(cipherObj, cipherText);
            cipherObj.Position = 0;
            StreamReader ciphersr   = new StreamReader(cipherObj, Encoding.UTF8);
            string       cipherjson = ciphersr.ReadToEnd().Replace("\\", "");

            ciphersr.Close();
            cipherObj.Close();

            Console.WriteLine("cipherjson:" + cipherjson);

            //加密后出金数据密文
            string encrypted = util.DesEncrypt(key, cipherjson);

            Console.WriteLine("Encrypted:" + encrypted);

            //解密密文
            Console.WriteLine("Descripted:" + util.DesDecrypt(key, encrypted));
        }
Exemple #2
0
        //入金数据加密示例
        static void checkWithdraw(FexpayUtils util, string key, string smac)
        {
            //编辑入金数据
            CheckWithdrawStructure data = new CheckWithdrawStructure();

            data.realName = Uri.EscapeDataString("实名02");
            data.amount   = "0.48";
            data.coinId   = "1";        // 1=BTC, 2=ETH, 3=UND
            data.idCard   = "2222222222";

            DataContractJsonSerializer js = new DataContractJsonSerializer(typeof(CheckWithdrawStructure));
            MemoryStream msObj            = new MemoryStream();

            js.WriteObject(msObj, data);
            msObj.Position = 0;
            StreamReader sr   = new StreamReader(msObj, Encoding.UTF8);
            string       json = sr.ReadToEnd().Replace("\\", "");

            sr.Close();
            msObj.Close();

            Console.WriteLine("\r\n=========出金验证===========");
            string sign = util.md5(json + smac).ToUpper();

            Console.WriteLine("json + smac:" + json + smac);
            Console.WriteLine("sign:" + sign);

            //编辑出金验证密文
            CheckWithdrawCipherTextStructure cipherText = new CheckWithdrawCipherTextStructure();

            cipherText.data = data;
            cipherText.sign = sign;

            DataContractJsonSerializer cipherjs = new DataContractJsonSerializer(typeof(CheckWithdrawCipherTextStructure));
            MemoryStream cipherObj = new MemoryStream();

            cipherjs.WriteObject(cipherObj, cipherText);
            cipherObj.Position = 0;
            StreamReader ciphersr   = new StreamReader(cipherObj, Encoding.UTF8);
            string       cipherjson = ciphersr.ReadToEnd().Replace("\\", "");

            ciphersr.Close();
            cipherObj.Close();

            Console.WriteLine("cipherjson:" + cipherjson);

            //加密后出金验证数据密文
            string encrypted = util.DesEncrypt(key, cipherjson);

            Console.WriteLine("Encrypted:" + encrypted);

            //解密密文
            Console.WriteLine("Descripted:" + util.DesDecrypt(key, encrypted));
        }
Exemple #3
0
        static void Main(string[] args)
        {
            string      Key  = "83A6AEDE-3B5A-4D3E-B789-DC780421C1A1";
            string      Smac = "C628C57D3F0FCB7652D9C5D64898DFFF";
            FexpayUtils util = new FexpayUtils();

            Key = util.md5(Key).Substring(0, 8).ToUpper();
            deposit(util, Key, Smac);
            checkWithdraw(util, Key, Smac);
            withdraw(util, Key, Smac);
        }