0

Can somebody know what is wrong with my code?

I kept getting error on this line below:

bool validSignature = pgp.VerifyString(verifyRichTextBox.Text, new FileInfo(openFileDialog1.FileName), out plainText);

The error is that the path is not of legal path.

Below is the full code:

public void verifyAll()
{
      OpenFileDialog openFileDialog1 = new OpenFileDialog();
      openFileDialog1.Title = "PLEASE CHOOSE SENDER'S PUBLIC KEY";

      string plainText;
      bool validSignature = pgp.VerifyString(verifyRichTextBox.Text, new FileInfo(openFileDialog1.FileName), out plainText);

      if (validSignature == true)
          verifyRichTextBox.Text = "Signature is valid!\n\n" + plainText;
      else
          MessageBox.Show("Signature is invalid!", "Invalid Signature", MessageBoxButtons.OK ,MessageBoxIcon.Exclamation);
}

This is a public/private key signing and verifying program. This part is the verifying part of a signed message. Everything uses didisoft OpenPGP.

Jens Erat
  • 37,523
  • 16
  • 80
  • 96
user2930173
  • 69
  • 2
  • 2
  • 8

1 Answers1

1

I think that your OpenFileDialog has not been executed. You can modify your code like this:

if (openFileDialog1.ShowDialog() == DialogResult.OK)
{
    string plainText;
    bool validSignature = pgp.VerifyString(verifyRichTextBox.Text, new FileInfo(openFileDialog1.FileName), out plainText);

    if (validSignature == true)
        verifyRichTextBox.Text = "Signature is valid!\n\n" + plainText;
    else
        MessageBox.Show("Signature is invalid!", "Invalid Signature", MessageBoxButtons.OK ,MessageBoxIcon.Exclamation);
}

You can also contact us directly using our official contact methods mentioned at http://www.didisoft.com/support/