Export (0) Print
Expand All

AesManaged Constructor

Initializes a new instance of the AesManaged class.

Namespace:  System.Security.Cryptography
Assembly:  System.Core (in System.Core.dll)

public AesManaged()

The following example demonstrates how to use the AesManaged constructor when you encrypt an isolated storage file. This code example is part of a larger example provided for the AesManaged class.


using (Aes aes = new AesManaged())
{
    Rfc2898DeriveBytes deriveBytes = new Rfc2898DeriveBytes(passwordBox.Password, Encoding.UTF8.GetBytes(PasswordSalt));
    aes.Key = deriveBytes.GetBytes(128 / 8);
    isoStoreStream.Write(BitConverter.GetBytes(aes.IV.Length), 0, sizeof(int));
    isoStoreStream.Write(aes.IV, 0, aes.IV.Length);

    using (CryptoStream cs = new CryptoStream(isoStoreStream, aes.CreateEncryptor(), CryptoStreamMode.Write))
    {
        byte[] rawPlaintext = Encoding.Unicode.GetBytes(inputBox.Text);
        cs.Write(rawPlaintext, 0, rawPlaintext.Length);
        cs.FlushFinalBlock();
    }
}


Silverlight

Supported in: 5, 4, 3

Silverlight for Windows Phone

Supported in: Windows Phone OS 7.1, Windows Phone OS 7.0

XNA Framework

Supported in: Windows Phone OS 7.0

For a list of the operating systems and browsers that are supported by Silverlight, see Supported Operating Systems and Browsers.

Community Additions

ADD
Show:
© 2014 Microsoft