Ejemplo n.º 1
0
        public void NoEncryptionTransformTest()
        {
            var encryption = new SymmetricEncryptionService(
                new SymmetricEncryptionConfiguration
            {
                AlgorithmType       = SymmetricAlgorithmType.None,
                PlainTextTransform  = StringTransform.FromEncoding(Encoding.UTF8),
                CipherTextTransform = StringTransform.GetBase64Transform()
            }
                );

            const string inputString      = InputStringTest;
            var          encryptionOutput = encryption.EncryptString(inputString, (string)null, null);
            var          base64String     = Convert.ToBase64String(Encoding.UTF8.GetBytes(inputString));

            Assert.AreEqual(base64String, encryptionOutput, "Encrypted string was not equal to the base64 hash of the input string.");
        }
Ejemplo n.º 2
0
        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;
        }