Rfc2898DeriveBytes.GetBytes Method

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

Returns a pseudo-random key from a password, salt and iteration count.

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

Syntax

'Declaration
Public Overrides Function GetBytes ( _
    cb As Integer _
) As Byte()
public override byte[] GetBytes(
    int cb
)

Parameters

  • cb
    Type: System.Int32
    The number of pseudo-random key bytes to generate.

Return Value

Type: array<System.Byte[]
A byte array filled with pseudo-random key bytes.

Exceptions

Exception Condition
ArgumentOutOfRangeException

cb is out of range. This parameter requires a non-negative number.

Remarks

The Rfc2898DeriveBytes class implements PBKDF2 functionality by using a pseudorandom number generator based on HMACSHA1. The Rfc2898DeriveBytes class takes a password, a salt, and an iteration count, and then generates keys through calls to the GetBytes method. Repeated calls to this method will not generate the same key; instead, appending two calls of the GetBytes method with a cb parameter value of 20 is the equivalent of calling the GetBytes method once with a cb parameter value of 40.

Version Information

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

Platforms

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