[Adapdev-commits] Adapdev/src/Adapdev.Tests/Cryptography CryptoTest.cs,1.5,1.6
Status: Beta
Brought to you by:
intesar66
From: Sean M. <int...@us...> - 2006-03-01 01:38:55
|
Update of /cvsroot/adapdev/Adapdev/src/Adapdev.Tests/Cryptography In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv6213/src/Adapdev.Tests/Cryptography Modified Files: CryptoTest.cs Log Message: Index: CryptoTest.cs =================================================================== RCS file: /cvsroot/adapdev/Adapdev/src/Adapdev.Tests/Cryptography/CryptoTest.cs,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** CryptoTest.cs 21 Feb 2006 04:31:17 -0000 1.5 --- CryptoTest.cs 1 Mar 2006 01:38:51 -0000 1.6 *************** *** 24,27 **** --- 24,63 ---- [Test] + public void EncryptDecryptDPAPI() + { + try + { + string text = "Hello, world!"; + string entropy = null; + string description; + + Console.WriteLine("Plaintext: {0}\r\n", text); + + // Call DPAPI to encrypt data with user-specific key. + string encrypted = DPAPI.Encrypt( DPAPI.KeyType.UserKey, + text, + entropy, + "My Data"); + Console.WriteLine("Encrypted: {0}\r\n", encrypted); + + // Call DPAPI to decrypt data. + string decrypted = DPAPI.Decrypt( encrypted, + entropy, + out description); + Console.WriteLine("Decrypted: {0} <<<{1}>>>\r\n", + decrypted, description); + } + catch (Exception ex) + { + while (ex != null) + { + Console.WriteLine(ex.Message); + ex = ex.InnerException; + } + } + + } + + [Test] public void EncryptDecryptDes() { |