當前位置: 首頁>>代碼示例>>C#>>正文


C# ASN1.Find方法代碼示例

本文整理匯總了C#中Mono.Security.ASN1.Find方法的典型用法代碼示例。如果您正苦於以下問題:C# ASN1.Find方法的具體用法?C# ASN1.Find怎麽用?C# ASN1.Find使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Mono.Security.ASN1的用法示例。


在下文中一共展示了ASN1.Find方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。

示例1: ReadCard

        private void ReadCard(object o)
        {
            UseHourglass(true);
            string selectedReader = o as string;
            UpdateStatusLabel("Reading card...");

            TreeView treeView = new TreeView();
            TreeNode cardNode = new TreeNode("Card");
            cardNode.ImageIndex = 0;
            cardNode.SelectedImageIndex = 0;
            treeView.Nodes.Add(cardNode);

            // Tree nodes
            TreeNode pseNode = null;
            TreeNode fciNode = null;
            ASN1 fci = null;
            List<byte[]> pseIdentifiers = new List<byte[]>();
            List<byte[]> applicationIdentifiers = new List<byte[]>();
            ASCIIEncoding encoding = new ASCIIEncoding();
            APDUCommand apdu = null;
            APDUResponse response = null;
            bool pseFound = false;

            if (!skipPSEToolStripMenuItem.Checked)
            {
                pseIdentifiers.Add(encoding.GetBytes("1PAY.SYS.DDF01"));
                pseIdentifiers.Add(encoding.GetBytes("2PAY.SYS.DDF01"));
            }

            try
            {
                // Now lets process all Payment System Environments
                if (pseIdentifiers.Count > 0)
                {
                    cardReader.Connect(selectedReader);

                    foreach (byte[] pse in pseIdentifiers)
                    {
                        apdu = new APDUCommand(0x00, 0xA4, 0x04, 0x00, pse, (byte)pse.Length);
                        response = cardReader.Transmit(apdu);

                        // Get response nescesary
                        if (response.SW1 == 0x61)
                        {
                            apdu = new APDUCommand(0x00, 0xC0, 0x00, 0x00, null, response.SW2);
                            response = cardReader.Transmit(apdu);
                        }

                        // PSE application read found ok
                        if (response.SW1 == 0x90)
                        {
                            pseFound = true;

                            pseNode = new TreeNode(String.Format("Application {0}", encoding.GetString(pse)));
                            pseNode.ImageIndex = 1;
                            pseNode.SelectedImageIndex = 1;
                            pseNode.Tag = pse;
                            cardNode.Nodes.Add(pseNode);

                            fciNode = new TreeNode("File Control Information");
                            fciNode.ImageIndex = 3;
                            fciNode.SelectedImageIndex = 3;
                            fciNode.Tag = "fci";
                            pseNode.Nodes.Add(fciNode);

                            fci = new ASN1(response.Data);
                            AddRecordNodes(fci, fciNode);

                            byte sfi = new ASN1(response.Data).Find(0x88).Value[0];
                            byte recordNumber = 0x01;
                            byte p2 = (byte)((sfi << 3) | 4);

                            TreeNode efDirNode = new TreeNode(String.Format("EF Directory - {0:X2}", sfi));
                            efDirNode.ImageIndex = 2;
                            efDirNode.SelectedImageIndex = 2;
                            efDirNode.Tag = sfi;
                            pseNode.Nodes.Add(efDirNode);

                            while (response.SW1 != 0x6A && response.SW2 != 0x83)
                            {
                                apdu = new APDUCommand(0x00, 0xB2, recordNumber, p2, null, 0x00);
                                response = cardReader.Transmit(apdu);

                                // Retry with correct length
                                if (response.SW1 == 0x6C)
                                {
                                    apdu = new APDUCommand(0x00, 0xB2, recordNumber, p2, null, response.SW2);
                                    response = cardReader.Transmit(apdu);
                                }

                                if (response.SW1 == 0x61)
                                {
                                    apdu = new APDUCommand(0x00, 0xC0, 0x00, 0x00, null, response.SW2);
                                    response = cardReader.Transmit(apdu);
                                }

                                if (response.Data != null)
                                {
                                    TreeNode recordNode = new TreeNode(String.Format("Record - {0:X2}", recordNumber));
                                    recordNode.ImageIndex = 4;
//.........這裏部分代碼省略.........
開發者ID:Zengwn,項目名稱:CardBrowser,代碼行數:101,代碼來源:MainForm.cs


注:本文中的Mono.Security.ASN1.Find方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。