diff options
author | Andrew Arnott <andrewarnott@gmail.com> | 2010-05-31 08:05:20 -0700 |
---|---|---|
committer | Andrew Arnott <andrewarnott@gmail.com> | 2010-05-31 08:05:20 -0700 |
commit | d5b264fed4bb3b0adb881ccaac3ae0a52ead7c56 (patch) | |
tree | d3b0a8a6d3cb36f7a95df7e2ff234080a54c0fea /src/DotNetOpenAuth.Test/Messaging/MessagingUtilitiesTests.cs | |
parent | ad60330d66985c4892b7e0b7ddb424be9ca867c8 (diff) | |
download | DotNetOpenAuth-d5b264fed4bb3b0adb881ccaac3ae0a52ead7c56.zip DotNetOpenAuth-d5b264fed4bb3b0adb881ccaac3ae0a52ead7c56.tar.gz DotNetOpenAuth-d5b264fed4bb3b0adb881ccaac3ae0a52ead7c56.tar.bz2 |
Added symmetric key encryption/decryption utility methods.
Diffstat (limited to 'src/DotNetOpenAuth.Test/Messaging/MessagingUtilitiesTests.cs')
-rw-r--r-- | src/DotNetOpenAuth.Test/Messaging/MessagingUtilitiesTests.cs | 15 |
1 files changed, 13 insertions, 2 deletions
diff --git a/src/DotNetOpenAuth.Test/Messaging/MessagingUtilitiesTests.cs b/src/DotNetOpenAuth.Test/Messaging/MessagingUtilitiesTests.cs index 2b0e8f9..1e0ede5 100644 --- a/src/DotNetOpenAuth.Test/Messaging/MessagingUtilitiesTests.cs +++ b/src/DotNetOpenAuth.Test/Messaging/MessagingUtilitiesTests.cs @@ -4,8 +4,7 @@ // </copyright> //----------------------------------------------------------------------- -namespace DotNetOpenAuth.Test.Messaging -{ +namespace DotNetOpenAuth.Test.Messaging { using System; using System.Collections.Generic; using System.Collections.Specialized; @@ -216,5 +215,17 @@ namespace DotNetOpenAuth.Test.Messaging public void GetHttpDeliveryMethodOutOfRangeTest() { MessagingUtilities.GetHttpDeliveryMethod("UNRECOGNIZED"); } + + [TestCase] + public void EncryptDecrypt() { + const string PlainText = "Hi folks!"; + byte[] key = MessagingUtilities.GetCryptoRandomData(128 / 8); + var cipher = MessagingUtilities.Encrypt(PlainText, key); + + Console.WriteLine("Encrypted \"{0}\" ({1} length) to {2} encrypted bytes.", PlainText, PlainText.Length, cipher.Length); + + string roundTripped = MessagingUtilities.Decrypt(cipher, key); + Assert.AreEqual(PlainText, roundTripped); + } } } |