CSharpTest.Net
AESCryptoKey Class
Members  Example  See Also  Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Crypto Namespace : AESCryptoKey Class

Glossary Item Box

Provides AES-256 bit encryption using a global IV (Init vector) based on the current process' entry assembly.

Syntax

Visual Basic (Declaration) 
Public Class AESCryptoKey 
   Inherits CryptoKey
   Implements IEncryptDecrypt 
C# 
public class AESCryptoKey : CryptoKey, IEncryptDecrypt  

Example

Library/Library.Test/TestEncryption.cs

C#Copy Code
byte[] original = AESCryptoKey.ProcessDefaultIV;
try
{
    Assert.AreEqual(original, new AESCryptoKey().IV);

    byte[] newIv = new byte[16];
    new Random().NextBytes(newIv);
    AESCryptoKey.ProcessDefaultIV = newIv;

    Assert.AreEqual(newIv, AESCryptoKey.ProcessDefaultIV);
    Assert.AreEqual(newIv, new AESCryptoKey().IV);
}
finally
{
    AESCryptoKey.ProcessDefaultIV = original;
}
VB.NETCopy Code
Dim original As Byte() = AESCryptoKey.ProcessDefaultIV
Try
    Assert.AreEqual(original, New AESCryptoKey().IV)

    Dim newIv As Byte() = New Byte(16) {}
    New Random().NextBytes(newIv)
    AESCryptoKey.ProcessDefaultIV = newIv

    Assert.AreEqual(newIv, AESCryptoKey.ProcessDefaultIV)
    Assert.AreEqual(newIv, New AESCryptoKey().IV)
Finally
    AESCryptoKey.ProcessDefaultIV = original
End Try

Inheritance Hierarchy

System.Object
   CSharpTest.Net.Crypto.CryptoKey
      CSharpTest.Net.Crypto.AESCryptoKey

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Generated with Document! X 2011 by Innovasys