コード例 #1
0
        public string BuildPart55Data(string terminalNo, string TransActionType, string money, string sysTraceNum)
        {
            byte[] bytes = ASCIIEncoding.ASCII.GetBytes(terminalNo);
            terminalNo = BitConverter.ToString(bytes).Replace("-", "");
            //55域数据
            StringBuilder builder = new StringBuilder();

            builder.Append(TLVUtil.GetTLVByTv("9F26", this.AC));
            builder.Append(TLVUtil.GetTLVByTv("9F27", this.CID));
            builder.Append(TLVUtil.GetTLVByTv("9F10", this.IssBankAppData));
            builder.Append(TLVUtil.GetTLVByTv("9F37", this.RadomData));
            builder.Append(TLVUtil.GetTLVByTv("9F36", this.ATC));
            builder.Append(TLVUtil.GetTLVByTv("95", PublicStaticData.TVR));
            builder.Append(TLVUtil.GetTLVByTv("9A", DateTime.Now.ToString("yyMMdd")));
            builder.Append(TLVUtil.GetTLVByTv("9C", TransActionType));
            builder.Append(TLVUtil.GetTLVByTv("9F02", money));
            builder.Append(TLVUtil.GetTLVByTv("5F2A", MonetaryCode.RMB));
            builder.Append(TLVUtil.GetTLVByTv("82", this.AIP));
            builder.Append(TLVUtil.GetTLVByTv("9F1A", "0156"));
            builder.Append(TLVUtil.GetTLVByTv("9F03", "000000000000"));
            builder.Append(TLVUtil.GetTLVByTv("9F33", "E04820"));                    //终端性能
            builder.Append(TLVUtil.GetTLVByTv("9F34", "3F0300"));                    //持卡人验证结果
            builder.Append(TLVUtil.GetTLVByTv("9F35", "24"));                        //终端类型
            builder.Append(TLVUtil.GetTLVByTv("9F1E", terminalNo));                  //接口设备序列号
            builder.Append(TLVUtil.GetTLVByTv("84", AID));                           //专用文件名称
            builder.Append(TLVUtil.GetTLVByTv("9F09", this.AppVersionNo));           //应用版本号
            builder.Append(TLVUtil.GetTLVByTv("9F41", sysTraceNum.PadLeft(8, '0'))); //交易序列计数器
            if (!string.IsNullOrEmpty(this.ProductId))
            {
                builder.Append(TLVUtil.GetTLVByTv("9F63", this.ProductId));//卡产品序列号
            }
            return(builder.ToString());
        }
コード例 #2
0
ファイル: Receiver.cs プロジェクト: kxlcn/android-weixin
        private void decodeNotifyData(byte[] encryptData)
        {
            uint encryptAlgo  = Util.ReadProtoInt(encryptData, 1);
            uint compressAlgo = Util.ReadProtoInt(encryptData, 4);

            byte[] cipherText = Util.ReadProtoRawData(encryptData, 8);
            if (encryptAlgo == 5)
            {
                int    Salt         = (int)Util.ReadProtoInt(encryptData, 3);
                byte[] sencryptSalt = TLVUtil.int2byte(Salt, 4, false);
                byte[] sessionKey   = SessionPackMgr.getAccount().SessionKey;
                byte[] decodeKey    = new byte[20];

                Buffer.BlockCopy(sessionKey, 0, decodeKey, 0, 16);
                Buffer.BlockCopy(sencryptSalt, 0, decodeKey, 16, sencryptSalt.Length);

                byte[] decodeAesKey = MD5Core.GetHash(decodeKey);
                // Log.w("Network", string.Concat(new object[] { "encode notify salt ", Util.byteToHexStr(sencryptSalt), "SessionKey ", Util.byteToHexStr(sessionKey), "decode Key ", Util.byteToHexStr(decodeAesKey) }));
                byte[] decryptedData = Util.AESDecrypt(cipherText, decodeAesKey);

                if (compressAlgo == 1)
                {
                    Zlib.Decompress(decryptedData, decryptedData.Length, ref decryptedData);
                }

                Log.w("Network", string.Concat(new object[] { "decode notify result ", Util.byteToHexStr(decryptedData) }));

                cipherText = Util.ReadProtoRawData(decryptedData, 1);
                cipherText = Util.ReadProtoRawData(cipherText, 1);
                string ChatRoomId = Encoding.UTF8.GetString(cipherText);
                //  uint newMsgid = Util.ReadProtoInt(decryptedData, 2);

                uint newMsgSeq = Util.ReadProtoInt(decryptedData, 3);
                cipherText = Util.ReadProtoRawData(decryptedData, 6);
                cipherText = Util.ReadProtoRawData(cipherText, 1);
                string Contact = Encoding.UTF8.GetString(cipherText);

                uint msgType = Util.ReadProtoInt(decryptedData, 8);


                Log.w("Network", string.Concat(new object[] { "decode notify data ", " ChatRoomId ", ChatRoomId, " newMsgSeq ", newMsgSeq, "MsgType ", msgType, " Contact ", Contact }));


                new NetSceneGetChatRoomMsg().doScene(ChatRoomId, newMsgSeq);
            }
        }