private void OptionValidateDocument_Click(object sender, EventArgs e) { try { string toValidate = UploadedDocumentClass.GetFileContent(); DigitalSignatureClass signObject = new DigitalSignatureClass(); bool isValid = signObject.ValidateDocument(toValidate); LoadingScreenForm loadScreen = new LoadingScreenForm(UploadedDocumentClass.GetFileName(), "Validating Signature"); loadScreen.ShowDialog(); if (isValid) { MessageBox.Show("Signature is VALID", "Success", MessageBoxButtons.OK, MessageBoxIcon.Information); } else { MessageBox.Show("Signature is NOT valid", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } } catch { MessageBox.Show("Signature is NOT valid", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
private void OptionSignDocument_Click(object sender, EventArgs e) { string toSign = UploadedDocumentClass.GetFileContent(); DigitalSignatureClass signObject = new DigitalSignatureClass(); string signedDocument = signObject.SignDocument(toSign); LoadingScreenForm loadScreen = new LoadingScreenForm(UploadedDocumentClass.GetFileName(), "Digital Signature"); loadScreen.ShowDialog(); SaveToTxt("helpfile_signature", signedDocument + "\r\n" + toSign); outputScreen.Text = "SHA1 digest: \r\n" + signObject.GetDigestForSign(); outputScreen.Text += "\r\n\r\nSigned document: \r\n" + signedDocument; }