public void Read() { ct.RequestICC(); Thread.Sleep(200); ct.SelectFile(); Thread.Sleep(200); Console.WriteLine("ReadResult: " + Hexify(ct.Read(10, 10))); Console.WriteLine("ReadResult: " + Hexify(ct.Read(5, 10))); Console.WriteLine("ReadResult: " + Hexify(ct.Read(0, 10))); }
private void OnCardInserted() { try { byte [] data; // Read ASN1 data from card ct.SelectFile(); data = ct.Read(0, 80 - 4); Console.WriteLine("Card content: " + ct.Hexify(data, data.Length)); // Decode ASN1 struct // ASN1 root = new ASN1( data ); // Console.WriteLine( root ); } catch (CTException ex) { Console.WriteLine(ex); } catch (Exception ex) { Console.WriteLine("ASN1 parsing exception:"); Console.WriteLine(ex); } if (ActiveUserChanged != null) { ActiveUserChanged(); } }
protected virtual void OnExpander(object sender, System.EventArgs e) { if (!ContentFilled) { int lines = 15; byte[] data; // Fill Content View with data... Gtk.TextBuffer buffer = ContentView.Buffer; try { data = Ct.Read(0, lines * 16); for (int l = 0; l < lines; l++) { StringBuilder sb = new StringBuilder(80); sb.AppendFormat("{0:x4}: ", l * 16); for (int i = 0; i < 16; i++) { sb.AppendFormat("{0:x2} ", data[l * 16 + i]); } sb.Append("\n"); buffer.Insert(buffer.EndIter, sb.ToString()); } ContentFilled = true; } catch (CTException ex) { System.Console.Error.WriteLine(ex); } } }
// Card Inserted // Removed protected void OnCardInserted() { writeButton.Sensitive = true; nickEntry.Sensitive = true; nameEntry.Sensitive = true; door0Check.Sensitive = true; door1Check.Sensitive = true; // Check for Empty Or Labor Card byte[] data; try { ct.SelectFile(); data = ct.Read(0, 80); // Parse card data byte[] data2 = new byte[80 - 4]; Array.Copy(data, 4, data2, 0, 80 - 4); Console.WriteLine("Card content: " + ct.Hexify(data2, data2.Length)); // ASN1 root = new ASN1(data2); // System.Console.WriteLine( root ); // // EraseDialog erase = new EraseDialog(ct, // "Inserted card is not a Labor Card.\n\n" + // "<b>Delete card content and format as Labor Card?</b>" ); // erase.Run(); System.Console.WriteLine(ct.Hexify(data, data.Length)); } catch (CTException e) { System.Console.Error.WriteLine(e); CTError(); } SetStatusText("Card inserted"); }