RNGCryptoServiceProvider.GetBytes Method

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

Fills an array of bytes with a cryptographically strong sequence of random values.

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

Syntax

'Declaration
<SecuritySafeCriticalAttribute> _
Public Overrides Sub GetBytes ( _
    data As Byte() _
)
[SecuritySafeCriticalAttribute]
public override void GetBytes(
    byte[] data
)

Parameters

  • data
    Type: array<System.Byte[]
    The array to fill with a cryptographically strong sequence of random values.

Exceptions

Exception Condition
CryptographicException

The cryptographic service provider (CSP) cannot be acquired.

ArgumentNullException

data is nulla null reference (Nothing in Visual Basic).

Remarks

The length of the byte array determines how many cryptographically strong random bytes are produced.

This method is thread safe.

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.