Ejemplo n.º 1
0
        /// <summary>
        /// 签退
        /// </summary>
        /// <returns></returns>
        static Dictionary <string, ResultData> signOut()
        {
            Dictionary <int, string> data = new Dictionary <int, string>();

            data.Add(3, "000000");
            data.Add(11, "000006");
            data.Add(12, getHHMMSS());
            data.Add(41, "pos00001");
            data.Add(42, "000000000000257");
            data.Add(60, "22000003000");
            data.Add(63, "01");
            byte[] sendData = EncryptWT.EncryptData("0820", "6000000000", EncryptWT.encryptLKL(data, calculateMac(data, "0400")));
            Console.WriteLine(BCDUtil.byteArrToString(sendData));
            AnalysisBaseWT lk = new AnalysisBaseWT();

            byte[] result = Client(LakalaIp, LakalaPort, sendData);
            if (result.Length > 0)
            {
                return(lk.analysis(result)); //发送数据
            }
            else
            {
                return(null);
            }
        }
Ejemplo n.º 2
0
        /// <summary>
        /// 计算mac 公共类
        /// </summary>
        /// <param name="data"></param>
        /// <returns></returns>
        public static byte[] calculateMac(Dictionary <int, string> data, string msgType)
        {
            //计算MAC用到的数据
            byte[] countMacData = EncryptWT.countMacData(msgType, EncryptWT.encryptLKL(data, null));
            Console.WriteLine(BCDUtil.byteArrToString(countMacData));
            string str = MacUtils.CSMMAC(mackey, BCDUtil.byteArrToString(countMacData));

            Console.WriteLine("bcd2Str:" + PosProtocol.bcd2Str(System.Text.Encoding.Default.GetBytes(str.Substring(0, 8))));
            //MAC转byte[]
            String strMac = PosProtocol.bcd2Str(System.Text.Encoding.Default.GetBytes(str.Substring(0, 8).ToUpper()));

            byte[] macByte = BCDUtil.ToByteArray(strMac);
            return(macByte);
        }
Ejemplo n.º 3
0
        /// <summary>
        /// ZMK密钥下载
        /// </summary>
        /// <returns></returns>
        static void downKey()
        {
            Dictionary <int, string> data = new Dictionary <int, string>();

            data.Add(3, "060000");
            data.Add(11, "000002");
            data.Add(41, "pos00001");
            data.Add(42, "000000000000257");
            //data.Add(62, mackey);
            data.Add(63, "01");
            AnalysisBaseWT wt = new AnalysisBaseWT();

            byte[] result = Client(LakalaIp, LakalaPort, EncryptWT.EncryptData("0800", "6000000000", EncryptWT.encryptLKL(data, null))); //发送数据
            Dictionary <string, ResultData> rd = wt.analysis(result);

            sonKey = validateKey(rd["62"].value, matherKey);
            printInfo(rd);
        }
Ejemplo n.º 4
0
        /// <summary>
        /// 签到
        /// </summary>
        /// <returns></returns>
        static Dictionary <string, ResultData> sign()
        {
            //签到


            Dictionary <int, string> data = new Dictionary <int, string>();

            data.Add(3, "000000");
            data.Add(11, "000008");
            data.Add(41, "pos00001");
            data.Add(42, "000000000000257");
            data.Add(63, "01");
            byte[] result = Client(LakalaIp, LakalaPort, EncryptWT.EncryptData("0800", "6000000000", EncryptWT.encryptLKL(data, null))); //发送数据
            if (result == null || result.Length <= 0)
            {
                return(null);
            }

            Console.WriteLine(BCDUtil.byteArrToString(result));
            AnalysisBaseWT lk = new AnalysisBaseWTSign();
            Dictionary <string, ResultData> rd = lk.analysis(result);

            return(rd);
        }