private void DEDecryptButton_Click(object sender, RoutedEventArgs e) { //Create a DigitalEnvelope object that will load all the necessary properties from saved files. DigitalEnvelope digitalEnvelope = new DigitalEnvelope(DEInputEnvelopeTextBox.Text, DEInputPrivateKeyTextBox.Text); byte[] result = digitalEnvelope.DecryptEnvelope(); //If the result of the decryption is null an error must have occurred. DEInputTextBlock.Text = result != null?Encoding.Unicode.GetString(result) : "Envelope could not be decrypted!"; }
private void DCAuthenticateCertificateButton_Click(object sender, RoutedEventArgs e) { //Create a DigitalEnvelope object that will load all the necessary properties from saved files. DigitalEnvelope digitalEnvelope = new DigitalEnvelope(DCInputEnvelopeTextBox.Text, DCInputEnvelopePrivateKeyTextBox.Text); //Create a DigitalSignature object that will load all the necessary properties from saved files and the DigitalEnvelope object. DigitalSignature digitalSignature = new DigitalSignature(digitalEnvelope.DigitalEnvelopeEncrypted.EncryptedDataKeyPair(), DCInputSignatureTextBox.Text, DCInputSignaturePublicKeyTextBox.Text); if (digitalSignature.AuthenticateSignature()) { DCInputTextBlock.Text = "Signature valid!"; } else { DCInputTextBlock.Text = "Signature invalid!"; return; } byte[] result = digitalEnvelope.DecryptEnvelope(); string decryptedEnvelope = result != null?Encoding.Unicode.GetString(result) : "Envelope could not be decrypted!"; DCInputTextBlock.Text += "\n\n-----------------------------------------------\n" + decryptedEnvelope; }