AesManaged.IV Property

Microsoft Silverlight will reach end of support after October 2021. Learn more.

Gets or sets the initialization vector (IV) to use for the symmetric algorithm.

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


Public Overrides Property IV As Byte()
public override byte[] IV { get; set; }

Property Value

Type: array<System.Byte[]
The initialization vector to use for the symmetric algorithm


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

Using aes = New System.Security.Cryptography.AesManaged()
    Dim deriveBytes As New Rfc2898DeriveBytes(decryptPassWordBox.Password, Encoding.UTF8.GetBytes(PasswordSalt))
    aes.Key = deriveBytes.GetBytes(128 / 8)
    ' Get the initialization vector from the encrypted stream
    aes.IV = ReadByteArray(isoStoreStream)
    Dim cs As New CryptoStream(isoStoreStream, aes.CreateDecryptor(), CryptoStreamMode.Read)
    Dim reader As New StreamReader(cs, Encoding.Unicode)
        Dim retval As String
        retval = reader.ReadToEnd()
        Return retval
    Catch e As Exception
        Return e.ToString()
    End Try
End Using
using (Aes aes = new AesManaged())
    Rfc2898DeriveBytes deriveBytes = new Rfc2898DeriveBytes(decryptPassWordBox.Password, Encoding.UTF8.GetBytes(PasswordSalt));
    aes.Key = deriveBytes.GetBytes(128 / 8);
    // Get the initialization vector from the encrypted stream
    aes.IV = ReadByteArray(isoStoreStream);
    CryptoStream cs = new CryptoStream(isoStoreStream, aes.CreateDecryptor(), CryptoStreamMode.Read);
    StreamReader reader = new StreamReader(cs, Encoding.Unicode);
        string retval = reader.ReadToEnd();
        return retval;
    catch (Exception e)
        return e.ToString();


Version Information


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.