RNGCryptoServiceProvider.GetNonZeroBytes Método

Definición

Sobrecargas

GetNonZeroBytes(Byte[])

Rellena una matriz de bytes con una secuencia aleatoria de valores distintos de cero sólidamente cifrada.

GetNonZeroBytes(Span<Byte>)

Rellena un intervalo de bytes con una secuencia aleatoria criptográficamente segura de valores distintos de cero.

GetNonZeroBytes(Byte[])

Rellena una matriz de bytes con una secuencia aleatoria de valores distintos de cero sólidamente cifrada.

public:
 override void GetNonZeroBytes(cli::array <System::Byte> ^ data);
public override void GetNonZeroBytes (byte[] data);
override this.GetNonZeroBytes : byte[] -> unit
Public Overrides Sub GetNonZeroBytes (data As Byte())

Parámetros

data
Byte[]

La matriz para rellenar la secuencia aleatoria de valores distintos de cero sólidamente cifrada.

Excepciones

No se puede adquirir el proveedor de servicios criptográficos (CSP).

data es null.

Ejemplos

En el ejemplo de código siguiente se crea una secuencia aleatoria de 100 bytes distintos de cero y se almacena en random.

array<Byte>^ random = gcnew array<Byte>(100);
//RNGCryptoServiceProvider is an implementation of a random number generator.
RNGCryptoServiceProvider^ rng = gcnew RNGCryptoServiceProvider;
rng->GetNonZeroBytes( random ); // The array is now filled with cryptographically strong random bytes, and none are zero.
byte[] random = new Byte[100];
//RNGCryptoServiceProvider is an implementation of a random number generator.
RNGCryptoServiceProvider rng = new RNGCryptoServiceProvider();
rng.GetNonZeroBytes(random); // The array is now filled with cryptographically strong random bytes, and none are zero.
Dim random() As Byte = New Byte(100) {}
'RNGCryptoServiceProvider is an implementation of an RNG
Dim rng As New RNGCryptoServiceProvider()
rng.GetNonZeroBytes(random) ' bytes in random are now random and none are zero

Comentarios

La longitud de la matriz de bytes determina cuántos bytes aleatorios no cero se generan criptográficamente seguros.

Consulte también

Se aplica a

GetNonZeroBytes(Span<Byte>)

Rellena un intervalo de bytes con una secuencia aleatoria criptográficamente segura de valores distintos de cero.

public:
 override void GetNonZeroBytes(Span<System::Byte> data);
public override void GetNonZeroBytes (Span<byte> data);
override this.GetNonZeroBytes : Span<byte> -> unit
Public Overrides Sub GetNonZeroBytes (data As Span(Of Byte))

Parámetros

data
Span<Byte>

Intervalo que se va a rellenar con bytes aleatorios criptográficamente seguros distintos de cero.

Se aplica a