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 OptionEncryptAES_Click(object sender, EventArgs e) { SymmetricCryptography encrypterAES = new SymmetricCryptography(false); string contentToEncrypt = UploadedDocumentClass.GetFileContent(); string encrypted = encrypterAES.EncryptDocumentAES(contentToEncrypt); LoadingScreenForm loadScreen = new LoadingScreenForm(UploadedDocumentClass.GetFileName(), "AES Encryption"); loadScreen.ShowDialog(); SaveToTxt("helpfile_aes_encrypted", encrypted); outputScreen.Text = "Encrypted with AES: \r\n" + encrypted; }
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; }
private void OptionEncryptRSA_Click(object sender, EventArgs e) { AsymmetricCryptography encrypterRSA = new AsymmetricCryptography(); encrypterRSA.GenerateKeys(); string contentToEncrypt = UploadedDocumentClass.GetFileContent(); string encrypted = encrypterRSA.EncryptDocumentRSA(contentToEncrypt); LoadingScreenForm loadScreen = new LoadingScreenForm(UploadedDocumentClass.GetFileName(), "RSA Encryption"); loadScreen.ShowDialog(); SaveToTxt("helpfile_rsa_encrypted", encrypted); outputScreen.Text = "Encrypted with RSA: \r\n" + encrypted; }
/// <summary> /// Metoda koja se poziva na klik tipke za SHA1 sažimanje /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void OptionSHA1Digest_Click(object sender, EventArgs e) { string docContent = UploadedDocumentClass.GetFileContent(); SHADigestClass shaObject = new SHADigestClass(docContent); string calculatedDigest = ""; shaObject.GetDigest(); calculatedDigest = shaObject.GetStringDigest(); SaveToTxt("helpfile_sha1_digest", calculatedDigest); LoadingScreenForm loadScreen = new LoadingScreenForm(UploadedDocumentClass.GetFileName(), "SHA1 Digest"); loadScreen.ShowDialog(); outputScreen.Text = "SHA1 digest: \r\n" + calculatedDigest; }
private void OptionDecryptAES_Click(object sender, EventArgs e) { try { SymmetricCryptography decrypterAES = new SymmetricCryptography(true); string contentToDecrypt = UploadedDocumentClass.GetFileContent(); string decrypted = decrypterAES.DecryptDocumentAES(contentToDecrypt); LoadingScreenForm loadScreen = new LoadingScreenForm(UploadedDocumentClass.GetFileName(), "AES Decryption"); loadScreen.ShowDialog(); SaveToTxt("helpfile_aes_decrypted", decrypted); outputScreen.Text = "Decrypted with AES: \r\n" + decrypted; } catch { MessageBox.Show("Document is not valid AES encryption", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } }