예제 #1
0
        private void btnZtDataDecrypt_Click(object sender, EventArgs e)
        {
            string org = this.txtZtOrgData.Text.Trim();

            this.SetParam();
            if (org.Length == 0)
            {
                MessageBox.Show("源字符串的长度必须大于0!");
                this.txtZtOrgData.Focus();
                return;
            }
            if (org.Length % 16 != 0)
            {
                MessageBox.Show("源字符串的长度必须是16的倍数!");
                this.txtZtOrgData.Focus();
                return;
            }
            Zt598Importer.ZT_EPP_ActivWorkPin(this.ztMainId, this.ztWorkId);
            StringBuilder dest = new StringBuilder(255);
            int           ret  = Zt598Importer.ZT_EPP_PinUnAdd(this.ztPEAMode, 0, org, dest);

            this.lbZtHint.Text        = "解密数据返回code:" + ret;
            this.txtZtResultData.Text = dest.ToString();
            if (ret == 0)
            {
                this.txtZtResultData.Text = dest.ToString();
            }
        }
예제 #2
0
        private void btnZtDownWorkKey_Click(object sender, EventArgs e)
        {
            StringBuilder cpExChk = new StringBuilder(255);
            int           ret     = Zt598Importer.ZT_EPP_PinLoadWorkKey(1, Convert.ToInt32(this.txtZtDownMasterKeyIndex.Text), Convert.ToInt32(this.txtZtDownWorkKeyIndex.Text), this.txtZtDownWorkKey.Text, cpExChk);

            this.lbZtHint.Text = "下载工作密钥返回code:" + ret + "检验值:" + cpExChk.ToString();
        }
예제 #3
0
        private void btnZtBeginUnInput_Click(object sender, EventArgs e)
        {
            this.txtZtInputData.Text = "";
            this.AllowZtInput        = true;
            Zt598Importer.ZT_EPP_OpenKeyVoic(3);
            ThreadExecutor thread = new ThreadExecutor(ZtUnEncryptInput);

            thread.BeginInvoke(null, null);
        }
예제 #4
0
        private void btnZtOpenDevice_Click(object sender, EventArgs e)
        {
            int ret = Zt598Importer.ZT_EPP_OpenCom(Convert.ToInt32(this.txtZtPort.Text), 9600);

            this.lbZtHint.Text = "打开串口返回code:" + ret;
            if (ret == 0)
            {
                this.EnabledButton(this.tabControl1.TabPages[4], this.btnZtOpenDevice, true);
            }
        }
예제 #5
0
        private void btnZtGetVersion_Click(object sender, EventArgs e)
        {
            StringBuilder sbVersion = new StringBuilder(255);
            StringBuilder sbSn      = new StringBuilder(255);
            StringBuilder sbRechang = new StringBuilder(255);
            int           ret       = Zt598Importer.ZT_EPP_PinReadVersion(sbVersion, sbSn, sbRechang);

            this.lbZtHint.Text = "版本信息:" + sbVersion.ToString() + " 生产序号:" + sbSn.ToString()
                                 + " 描述代码" + sbRechang.ToString();
        }
예제 #6
0
        private void btnZtCloseDevice_Click(object sender, EventArgs e)
        {
            int ret = Zt598Importer.ZT_EPP_CloseCom();

            this.lbZtHint.Text = "打开串口返回code:" + ret;
            if (ret == 0)
            {
                this.EnabledButton(this.tabControl1.TabPages[4], this.btnZtOpenDevice, false);
            }
        }
예제 #7
0
        private void ZtPwdEncryptInput()
        {
            int           result = 0;
            StringBuilder msg    = new StringBuilder(32);

            while (AllowZtInput)
            {
                result = Zt598Importer.ZT_EPP_PinReportPressed(msg, 100);
                // this.txtZtUserPwd.Text += msg.ToString();
                if (result == 0)
                {
                    if (msg.ToString()[0] == 0x08)//更正8
                    {
                        this.txtZtUserPwd.Text = "";
                        this.txtZtUserPwdEncryptResult.Text = "";
                        this.pwdNowLen = 0;
                    }
                    else if (msg.ToString()[0] == 0x0D)//确认13
                    {
                        AllowZtInput = false;
                        if (ztPinMode == 0)
                        {
                            Zt598Importer.ZT_EPP_PinLoadCardNo(this.txtZtEncryptPan.Text);
                            Zt598Importer.ZT_EPP_ActivWorkPin(this.ztMainId, this.ztWorkId);
                            Zt598Importer.ZT_EPP_SetDesPara(0x04, 0x00);
                        }
                        Zt598Importer.ZT_EPP_PinReadPin(ztPinMode == 0 ? this.ztPEAMode : 0, msg);
                        this.txtZtUserPwdEncryptResult.Text = msg.ToString();
                    }
                    else if (msg.ToString()[0] == 0x1B)//取消27
                    {
                        AllowZtInput           = false;
                        this.txtZtUserPwd.Text = "";
                        this.txtZtUserPwdEncryptResult.Text = "";
                    }
                    else
                    {
                        this.txtZtUserPwd.Text += msg.ToString();
                        pwdNowLen++;
                        if (pwdNowLen == pwdLen)
                        {
                            AllowZtInput = false;
                            if (ztPinMode == 0)
                            {
                                Zt598Importer.ZT_EPP_PinLoadCardNo(this.txtZtEncryptPan.Text);
                                Zt598Importer.ZT_EPP_ActivWorkPin(this.ztMainId, this.ztWorkId);
                                Zt598Importer.ZT_EPP_SetDesPara(0x04, 0x00);
                            }
                            Zt598Importer.ZT_EPP_PinReadPin(ztPinMode == 0 ? this.ztPEAMode : 0, msg);
                            this.txtZtUserPwdEncryptResult.Text = msg.ToString();
                        }
                    }
                }
            }
        }
예제 #8
0
        private void ZtUnEncryptInput()
        {
            int           result = 0;
            StringBuilder msg    = new StringBuilder();

            while (AllowZtInput)
            {
                result = Zt598Importer.ZT_EPP_PinReportPressed(msg, 100);
                if (result == 0)
                {
                    this.txtZtInputData.Text += msg.ToString();
                }
            }
        }
예제 #9
0
        private void btnZtMAC_Click(object sender, EventArgs e)
        {
            string org = this.txtZtOrgData.Text.Trim();

            this.SetParam();
            Zt598Importer.ZT_EPP_ActivWorkPin(this.ztMainId, this.ztWorkId);
            StringBuilder dest = new StringBuilder(255);
            int           ret  = Zt598Importer.ZT_EPP_PinCalMAC(this.ztPEAMode, 1, org, dest);

            this.lbZtHint.Text = "MAC运算数据返回code:" + ret;
            if (ret == 0)
            {
                this.txtZtResultData.Text = dest.ToString();
            }
        }
예제 #10
0
        private void btnZtInputUserPwd_Click(object sender, EventArgs e)
        {
            this.SetParam();
            this.txtZtUserPwd.Text = "";

            this.AllowZtInput = true;

            pwdLen    = Convert.ToInt32(this.txtZtEncryptLength.Text);
            pwdNowLen = 0;
            ztPinMode = this.rbZtFrontEncrypt.Checked ? 1 : 0;
            if (ztPinMode == 1)
            {
                Zt598Importer.ZT_EPP_PinLoadCardNo(this.txtZtEncryptPan.Text);
                Zt598Importer.ZT_EPP_ActivWorkPin(this.ztMainId, this.ztWorkId);
            }
            Zt598Importer.ZT_EPP_OpenKeyVoic(2);
            Zt598Importer.ZT_EPP_PinStartAdd(Convert.ToInt32(this.txtZtEncryptLength.Text), 1, ztPinMode, 0, this.ztTimeout);
            ThreadExecutor thread = new ThreadExecutor(ZtPwdEncryptInput);

            thread.BeginInvoke(null, null);
        }
예제 #11
0
        private void btnZtGetEncryptData_Click(object sender, EventArgs e)
        {
            //int ret=0x08;//8
            // int ret2 = 0x0D;//13
            // int ret3 = 0x1B;//27
            // this.txtZtInputData.Text = ret.ToString()+"-"+ret2.ToString()+"-"+ret3.ToString();

            string org = this.txtZtUserPwdEncryptResult.Text.Trim();

            this.SetParam();

            Zt598Importer.ZT_EPP_ActivWorkPin(this.ztMainId, this.ztWorkId);
            StringBuilder dest = new StringBuilder(255);
            int           ret  = Zt598Importer.ZT_EPP_PinUnAdd(this.ztPEAMode, 0, org, dest);

            this.lbZtHint.Text = "解密数据返回code:" + ret;

            if (ret == 0)
            {
                this.txtZtUserPwdOrg.Text = dest.ToString().Substring(2).Replace("F", "");
            }
        }
예제 #12
0
 private void btnZtEndUnInput_Click(object sender, EventArgs e)
 {
     this.AllowZtInput = false;
     Zt598Importer.ZT_EPP_OpenKeyVoic(0);
 }
예제 #13
0
        private void btnZtActiveWorkKey_Click(object sender, EventArgs e)
        {
            int ret = Zt598Importer.ZT_EPP_ActivWorkPin(Convert.ToInt32(this.txtZtActiveWorkKeyMasterKeyIndex.Text), Convert.ToInt32(this.txtZtActiveWorkKeyWorkKeyIndex.Text));

            this.lbZtHint.Text = "激活工作密钥返回code:" + ret;
        }
예제 #14
0
        private void btnZtSetMathParam_Click(object sender, EventArgs e)
        {
            int ret = Zt598Importer.ZT_EPP_SetDesPara(Convert.ToInt32(this.txtZtMathP.Text), Convert.ToInt32(this.txtZtMathF.Text));

            this.lbZtHint.Text = "设置算法参数返回code:" + ret;
        }