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 signature. private void DSGenerateButton_Click(object sender, RoutedEventArgs e) { //Create a HashAlgorithmName object using the dropdown box selection. HashAlgorithmName hashAlgorithmName = HelperExtensions.StringToHashAlgorithm(DEHashDropdown.SelectedItem.ToString()); //Create a RSAWrapper object using the dropdown box selection and the HashAlgorithmName object. RSAWrapper rsaAlgorithm = new RSAWrapper(DSRsaDropdown.SelectedItem.ToString(), hashAlgorithmName); //Create a DigitalSignature object using the dropdown box selection and the RSAWrapper object. DigitalSignature digitalSignature = new DigitalSignature(rsaAlgorithm, DSInputTextBox.Text); digitalSignature.CreateSignature(); DSInputTextBlock.Text = "Signature generated successfully!"; }