Пример #1
0
        private void btnR_Click(object sender, RoutedEventArgs e)
        {
            Microsoft.Win32.OpenFileDialog openFileDialog = new Microsoft.Win32.OpenFileDialog();
            openFileDialog.Title            = "Select File";
            openFileDialog.Filter           = "TOK文件|*.TOK";
            openFileDialog.FileName         = string.Empty;
            openFileDialog.FilterIndex      = 1;
            openFileDialog.RestoreDirectory = true;
            if ((bool)openFileDialog.ShowDialog().GetValueOrDefault())
            {
                FileStream   fs      = new FileStream(openFileDialog.FileName, FileMode.Open);
                BinaryReader bw      = new BinaryReader(fs);
                byte[]       toDecry = new byte[fs.Length - 20];
                byte[]       Destbuf = new byte[fs.Length];

                byte[] readbuf = new byte[fs.Length];
                fs.Read(readbuf, 0, readbuf.Length);
                bw.Close();
                fs.Close();
                Array.Copy(readbuf, 20, toDecry, 0, toDecry.Length);
                byte[] inData = Convert.FromBase64String(System.Text.Encoding.UTF8.GetString(toDecry));

                byte[] Decryptbuf = Decrypt(inData);
                // [0, 21, 0, 0, 99, -121, 0, 0, 5, -113, 3, 0, 1, -78, 7, 69, 68, 66, 50, 52, 56, 50, 53, 32]
                Array.Copy(readbuf, 0, Destbuf, 0, 20);
                Array.Copy(Decryptbuf, 0, Destbuf, 20, Decryptbuf.Length);
                UsbKeyDataStruct tmp    = new UsbKeyDataStruct(Destbuf);
                KeyInfo          keywin = new KeyInfo(tmp);
                keywin.Show();
            }
        }
Пример #2
0
 public KeyInfo(UsbKeyDataStruct a)
 {
     InitializeComponent();
     tbCpr.Text = System.Text.Encoding.ASCII.GetString(a.copyright,0,20).TrimEnd('\0');
     tbId.Text = a.UsrID.ToString();
     tbPID.Text = a.PID.ToString();
     tbVID.Text = a.VID.ToString();
     tbSN.Text = System.Text.Encoding.ASCII.GetString(a.Sn);
     cbkeylv.Text = getlv(a.UsrLv);
 }
Пример #3
0
 public KeyInfo(UsbKeyDataStruct a)
 {
     InitializeComponent();
     tbCpr.Text   = System.Text.Encoding.ASCII.GetString(a.copyright, 0, 20).TrimEnd('\0');
     tbId.Text    = a.UsrID.ToString();
     tbPID.Text   = a.PID.ToString();
     tbVID.Text   = a.VID.ToString();
     tbSN.Text    = System.Text.Encoding.ASCII.GetString(a.Sn);
     cbkeylv.Text = getlv(a.UsrLv);
 }
Пример #4
0
 public MainWindow()
 {
     InitializeComponent();
     _UsbKeyDataStruct           = new UsbKeyDataStruct();
     devNotifier                 = DeviceNotifier.OpenDeviceNotifier();
     devNotifier.OnDeviceNotify += devNotifier_OnDeviceNotify;
     this.Loaded                += new RoutedEventHandler(MainWindow_Loaded);
     btnG.IsEnabled              = false;
     // byte[] aaa = new byte[12] { 0x35, 0x77, 0x61, 0x54, 0x42, 0x6A, 0x49, 0x44, 0x46, 0x2f, 0x34, 0x3d };
     //byte[] ret = Decrypt(aaa);
     // string aa = System.Text.Encoding.Default.GetString(ret);
     ;
 }
Пример #5
0
 public MainWindow()
 {
     InitializeComponent();
     _UsbKeyDataStruct = new UsbKeyDataStruct();
     devNotifier = DeviceNotifier.OpenDeviceNotifier();
     devNotifier.OnDeviceNotify += devNotifier_OnDeviceNotify;
     this.Loaded += new RoutedEventHandler(MainWindow_Loaded);
     btnG.IsEnabled =false;
    // byte[] aaa = new byte[12] { 0x35, 0x77, 0x61, 0x54, 0x42, 0x6A, 0x49, 0x44, 0x46, 0x2f, 0x34, 0x3d };
     //byte[] ret = Decrypt(aaa);
    // string aa = System.Text.Encoding.Default.GetString(ret);
     ;
 }
Пример #6
0
        public MainWindow()
        {
            InitializeComponent();
            _UsbKeyDataStruct           = new UsbKeyDataStruct();
            devNotifier                 = DeviceNotifier.OpenDeviceNotifier();
            devNotifier.OnDeviceNotify += devNotifier_OnDeviceNotify;
            this.Loaded                += new RoutedEventHandler(MainWindow_Loaded);
            btnG.IsEnabled              = false;
            Uri        uri = new Uri(@"disconnect.jpg", UriKind.Relative);
            ImageBrush ib  = new ImageBrush();

            ib.ImageSource    = new BitmapImage(uri);
            ib.Stretch        = Stretch.Uniform;
            lbicon.Background = ib;
        }
Пример #7
0
        private void btnR_Click(object sender, RoutedEventArgs e)
        {

            Microsoft.Win32.OpenFileDialog openFileDialog = new Microsoft.Win32.OpenFileDialog();
            openFileDialog.Title = "Select File";
            openFileDialog.Filter = "TOK文件|*.TOK";
            openFileDialog.FileName = string.Empty;
            openFileDialog.FilterIndex = 1;
            openFileDialog.RestoreDirectory = true;
            if ((bool)openFileDialog.ShowDialog().GetValueOrDefault())
            {
                FileStream fs = new FileStream(openFileDialog.FileName, FileMode.Open);
                BinaryReader bw = new BinaryReader(fs);
                byte[] toDecry = new byte[fs.Length - 20];
                byte[] Destbuf = new byte[fs.Length];

                byte[] readbuf = new byte[fs.Length];
                fs.Read(readbuf, 0, readbuf.Length);
                bw.Close();
                fs.Close();
                Array.Copy(readbuf, 20, toDecry, 0, toDecry.Length);
                byte[] inData = Convert.FromBase64String(System.Text.Encoding.UTF8.GetString(toDecry));

                byte[] Decryptbuf = Decrypt(inData);
               // [0, 21, 0, 0, 99, -121, 0, 0, 5, -113, 3, 0, 1, -78, 7, 69, 68, 66, 50, 52, 56, 50, 53, 32]
                Array.Copy(readbuf, 0, Destbuf, 0, 20);
                Array.Copy(Decryptbuf, 0, Destbuf, 20, Decryptbuf.Length);
                UsbKeyDataStruct tmp = new UsbKeyDataStruct(Destbuf);
                KeyInfo keywin = new KeyInfo(tmp);
                keywin.Show();
            }
        }