private void btnImportKey_Click(object sender, EventArgs e)
        {
            if (string.IsNullOrEmpty(txtFileToImport.Text))
            {
                lblResult.Text    = "Please specify file for key to import...";
                lblResult.Visible = true;
            }
            else
            {
                lblResult.Visible = false;
            }

            if (File.Exists(txtFileToImport.Text))
            {
                lblResult.Visible = false;
                ImportKey impKey   = new ImportKey();
                string    fileName = Path.GetFileName(txtFileToImport.Text);
                string    dirName  = Path.GetDirectoryName(txtFileToImport.Text);
                if (m_caller == "Secret")
                {
                    int cnt = impKey.ImportSecretKey(fileName, dirName, Global.keyDb);
                }
                else
                {
                    int cnt = impKey.ImportPublicKey(fileName, dirName, Global.keyDb);
                }
                lblResult.Text    = "Key imported successfully.";
                lblResult.Visible = true;
            }
            else
            {
                lblResult.Text    = "File specified does not exist!";
                lblResult.Visible = true;
            }
        }
Exemplo n.º 2
0
        async Task createKpFinish_CommitAsync(object sender, EventArgs e)
        {
            if (string.IsNullOrEmpty(txtFolder.Text))
            {
                txtFolder.Text = AppDomain.CurrentDomain.BaseDirectory;
            }
            bool runOk = await LynxPrivacyLib.GenerateKeys.GenerateKeyRing(txtFirstName.Text + " " + txtSurname.Text + " <" + txtEMail.Text + ">",
                                                                           m_passphrase1, txtFolder.Text);

            ImportKey impKey = new ImportKey();
            int       cntP   = impKey.ImportPublicKey(txtPublicKeyname.Text, txtFolder.Text, Global.keyDb);
            int       cntS   = impKey.ImportSecretKey(txtSecretKeyname.Text, txtFolder.Text, Global.keyDb);
        }
Exemplo n.º 3
0
        public async Task TestMethod1()
        {
            if (!m_keysGenerated)
            {
                await GenerateKeys.GenerateKeyRing("John W. Davidson <*****@*****.**>", new char[] { 'W', 'i', '7', 'a', 'r', 'd', 'r', 'y', '!', 'T', 'e', 's', 't' }, @"C:\Users\John\BcPGP\");

                m_keysGenerated = true;
            }
            ImportKey impKey = new ImportKey();

            using (KeyStoreDB keyDB = new KeyStoreDB()) {
                int cnt = impKey.ImportPublicKey("*****@*****.**", @"C:\Users\John\BcPGP", keyDB);
                Assert.IsTrue(cnt == 1);
            }
        }