Generates a symmetric key with a given size.
Namespace: Microsoft.IdentityModel
Assembly: Microsoft.IdentityModel (in microsoft.identitymodel.dll)

Usage

Visual Basic
Dim keySizeInBits As Integer
Dim returnValue As Byte()

returnValue = KeyGenerator.GenerateSymmetricKey(keySizeInBits)

Syntax

Visual Basic
Public Shared Function GenerateSymmetricKey ( _
		keySizeInBits As Integer _
) As Byte()
C#
public static byte[] GenerateSymmetricKey (
		int keySizeInBits
)
C++
public:
static array<unsigned char>^ GenerateSymmetricKey (
		int keySizeInBits
)
J#
public static byte[] GenerateSymmetricKey (
		int keySizeInBits
)
JScript
public static function GenerateSymmetricKey (
		keySizeInBits : int
) : byte[]

Parameters

keySizeInBits

The key size in bits.

Return Value

The symmetric key.

Exceptions

Exception type Condition

Remarks

This function should not be used to generate DES keys because it does not perform an IsWeakKey check. Use GenerateDESKey() instead.


Thread Safety

Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.

Platforms

Development Platforms

Windows Server 2003, Windows Vista

Target Platforms

Windows Server 2008, Windows Vista, Not tested on Windows XP

See Also