/// <summary> /// Initializes a new instance of <see cref="SymmetricEncryptionConfiguration"/> with default settings consisting of: /// <see cref="SymmetricAlgorithmType.Aes"/> encryption using <see cref="System.Security.Cryptography.CipherMode.CBC"/> and <see cref="System.Security.Cryptography.PaddingMode.PKCS7"/>. /// Plaintext strings are encoded using a UTF8 transform. /// All other strings (ciphertext, key, and IV strings) are encoded using a hex transform. /// </summary> public SymmetricEncryptionConfiguration() { AlgorithmType = SymmetricAlgorithmType.Aes; CipherMode = CipherMode.CBC; PaddingMode = PaddingMode.PKCS7; PlainTextTransform = StringTransform.FromEncoding(Encoding.UTF8); CipherTextTransform = StringTransform.GetHexTransform(); KeyTransform = StringTransform.GetHexTransform(); IvTransform = StringTransform.GetHexTransform(); }
private SymmetricEncryptionService CreateEncryptionService2() { return(new SymmetricEncryptionService( new SymmetricEncryptionConfiguration { AlgorithmType = GetAlgorithmType(), CipherMode = GetCipherMode(), PaddingMode = GetPaddingMode(), PlainTextTransform = cboPlainTextStringTransformType.SelectedValue as IStringTransform, CipherTextTransform = cboCipherTextStringTransformType.SelectedValue as IStringTransform, IvTransform = chkIvIsHex.Checked ? StringTransform.GetHexTransform() : StringTransform.FromEncoding(Encoding.Default), KeyTransform = chkKeyIsHex.Checked ? StringTransform.GetHexTransform() : StringTransform.FromEncoding(Encoding.Default) } )); }
public MainForm() { InitializeComponent(); cboPlainTextStringTransformType.Items.Clear(); cboCipherTextStringTransformType.Items.Clear(); // List of supported transforms var stringTransformTypes = new[] { new StringTransformComboBoxItem("Default Encoding", StringTransform.FromEncoding(Encoding.Default)), new StringTransformComboBoxItem("Base64", StringTransform.GetBase64Transform()), new StringTransformComboBoxItem("Hex", StringTransform.GetHexTransform()) }; // Each combo box gets its own copy of the transform list cboPlainTextStringTransformType.DataSource = new List <StringTransformComboBoxItem>(stringTransformTypes); cboCipherTextStringTransformType.DataSource = new List <StringTransformComboBoxItem>(stringTransformTypes); // Make sure we always select our first item cboPlainTextStringTransformType.SelectedIndex = 0; cboCipherTextStringTransformType.SelectedIndex = 0; }