Esempio n. 1
0
        public fShow(PDB p, Record r, int cIdx)
        {
            pdb = p;

            InitializeComponent();

            if (r.rTemplate)
            {
                this.Text = "Template in " + pdb.catMgr.GetCategoryName(r.rCategory);
            }
            else
            {
                this.Text = "Secret in " + pdb.catMgr.GetCategoryName(r.rCategory);
            }

            if (r.rTitle != null)
            {
                this.cShowTitle.Text = r.rTitle;
            }

            if (r.rSecret != null)
            {
                byte[] sec = new byte[r.rSecret.Length];
                uint   idx = 0;
                int    cnt;

                Array.Copy(r.rSecret, sec, sec.Length);

                for (cnt = 0; cnt < (sec.Length / 32); cnt++)
                {
                    pdb.aes.Decrypt(ref sec, idx);
                    pdb.aes.Decrypt(ref sec, idx + 16);
                    idx += 32;
                }

                for (cnt = 0; (cnt < sec.Length) && (sec[cnt] != 0); cnt++)
                {
                    ;
                }
                cShowSecret.Text            = pdb.encoder.GetString(sec, 0, cnt).Replace("\n", "\r\n");
                cShowSecret.SelectionStart  = cShowSecret.Text.Length + 1;
                cShowSecret.SelectionLength = 0;
            }
        }
Esempio n. 2
0
        /// <summary>
        /// Load the database to work on.
        /// </summary>
        /// <param name="dbName">Database name.</param>
        private void LoadDatabase(string dbName)
        {
            fPassword p = null;

            cMainCategory.Items.Clear();
            cMainListBox.Items.Clear();

            try
            {
                pdb = new PDB();

                pdb.PreLoad(dbName, "DATA", "iSec");

                p = new fPassword(dbName, pdb);

                p.ShowDialog();
                if ((p.password != null) && (p.password.Length > 0))
                {
                    pdb.Load(p.password);
                    config.currentDB  = dbName;
                    cMainStatBar.Text = pdb.Length + " Records in database";

                    categoryIdx = pdb.catMgr.GetCategoryIndex(config.categoryName);
                    SetupCategories();

                    cMainCategory.SelectedIndex = categoryIdx;
                    ChangeCategory();
                }
            } catch (Exception ex) {
                MessageBox.Show(ex.Message, "Load Error", MessageBoxButtons.OK);
                System.Environment.Exit(1);
            } finally {
                if (p != null)
                {
                    if ((p.password != null) && (p.password.Length > 0))
                    {
                        p.password.Remove(0, p.password.Length);
                    }
                    p.Dispose();
                }
            }
        }
Esempio n. 3
0
        public fPassword(string lbl, PDB pdb)
        {
            int pos;

            password = null;
            InitializeComponent();
            if ((pos = lbl.LastIndexOf(System.IO.Path.DirectorySeparatorChar)) == -1)
            {
                cPasswordLabel.Text = lbl;
            }
            else
            {
                cPasswordLabel.Text = lbl.Substring(pos + 1);
            }

            cPasswordFld.Focus();

            if ((hint = pdb.GetExtension(72)) != null)          // 'H'
            {
                cPasswordHint.Enabled = true;
            }
        }