private void DCGenerateCertificateButton_Click(object sender, RoutedEventArgs e) { //Create a RSAWrapper object using the dropdown box selection. RSAWrapper envelopeRsaAlgorithm = new RSAWrapper(DCEnvelopeRsaDropdown.SelectedItem.ToString()); //Create a CipherMode object using the dropdown box selection. CipherMode cipherMode = HelperExtensions.StringToCipherMode(DCEnvelopeCipherDropdown.SelectedItem.ToString()); //Create a SymmetricAlgorithmWrapper object using the dropdown box selection and the CipherMode object. SymmetricAlgorithmWrapper symmetricAlgorithmType = HelperExtensions.StringToSymAlg(DCEnvelopeSymDropdown.SelectedItem.ToString(), cipherMode, DCEnvelopeCipherDropdown.SelectedItem.ToString()); //Create a DigitalEnvelope object using the dropdown box selection, the SymmetricAlgorithmWrapper object and the RSAWrapper object. DigitalEnvelope digitalEnvelope = new DigitalEnvelope(symmetricAlgorithmType, envelopeRsaAlgorithm, DCInputTextBox.Text); //Decrypt the envelope. DigitalEnvelopeEncrypted result = digitalEnvelope.CreateEnvelope(); //Create a HashAlgorithmName object using the dropdown box selection. HashAlgorithmName hashAlgorithmName = HelperExtensions.StringToHashAlgorithm(DCSignatureHashDropdown.SelectedItem.ToString()); //Create a RSAWrapper object using the dropdown box selection and the HashAlgorithmName object. RSAWrapper rsaAlgorithm = new RSAWrapper(DCSignatureRsaDropdown.SelectedItem.ToString(), hashAlgorithmName); //Create a DigitalSignature object using the RSAWrapper object and the encrypted envelope data. DigitalSignature digitalSignature = new DigitalSignature(rsaAlgorithm, result.EncryptedDataKeyPair()); //Create a signature for the encrypted envelope data. digitalSignature.CreateSignature(); DCInputTextBlock.Text = "Certificate generated successfully!"; }
//Generate a digital envelope. private void DEGenerateButton_Click(object sender, RoutedEventArgs e) { //Create a CipherMode object using the dropdown box selection. CipherMode cipherMode = HelperExtensions.StringToCipherMode(DESymTypeDropdown.SelectedItem.ToString()); //Create a SymmetricAlgorithmWrapper object using the dropdown box selections and the CipherMode object. SymmetricAlgorithmWrapper symmetricAlgorithmType = HelperExtensions.StringToSymAlg(DESymDropdown.SelectedItem.ToString(), cipherMode, DESymTypeDropdown.SelectedItem.ToString()); //Create a RSAWrapper object using the dropdown box selection. RSAWrapper rsaAlgorithm = new RSAWrapper(DERsaDropdown.SelectedItem.ToString()); DigitalEnvelope digitalEnvelope = new DigitalEnvelope(symmetricAlgorithmType, rsaAlgorithm, DEInputTextBox.Text); digitalEnvelope.CreateEnvelope(); DEInputTextBlock.Text = "Envelope generated successfully!"; }