Beispiel #1
0
        private static void TestEncryption(AesWrapper aes)
        {
            const string stringToEncrypt = "hello, encrypted world!!!";

            var encrypted = aes.EncryptToString(stringToEncrypt);
            Assert.That(encrypted != null);
            Log.Info("Encrypted: {0}", encrypted);

            var decrypted = aes.DecryptFromString(encrypted);
            Assert.That(stringToEncrypt == decrypted);

            encrypted = aes.EncryptAsHexString(stringToEncrypt);
            Assert.That(encrypted != null);
            Log.Info("Encrypted: {0}", encrypted);

            decrypted = aes.DecryptFromHexString(encrypted);
            Assert.That(stringToEncrypt == decrypted);

            var encryptedData = aes.Encrypt(stringToEncrypt);
            Assert.That(encryptedData != null);
            var decryptedData = aes.Decrypt(encryptedData);
            Assert.That(decryptedData != null);
            Assert.That(Encoding.Unicode.GetString(decryptedData) == stringToEncrypt);
        }