Freigeben über


RandomNumberGenerator.GetNonZeroBytes-Methode

Füllt beim Überschreiben in einer abgeleiteten Klasse ein Bytearray mit einer kryptographisch starken Zufallsfolge von Werten, die ungleich 0 sind.

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

Syntax

'Declaration
Public MustOverride Sub GetNonZeroBytes ( _
    data As Byte() _
)
'Usage
Dim instance As RandomNumberGenerator
Dim data As Byte()

instance.GetNonZeroBytes(data)
public abstract void GetNonZeroBytes (
    byte[] data
)
public:
virtual void GetNonZeroBytes (
    array<unsigned char>^ data
) abstract
public abstract void GetNonZeroBytes (
    byte[] data
)
public abstract function GetNonZeroBytes (
    data : byte[]
)

Parameter

  • data
    Das mit kryptographisch starken, zufälligen Bytes ungleich 0 auszufüllende Array.

Hinweise

Die Länge des Bytearrays bestimmt die Anzahl der erzeugten Zufallsbytes.

Beispiel

Im folgenden Beispiel wird eine Zufallsfolge von 100 Bytes erstellt, die ungleich 0 sind, und in random gespeichert.

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
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.
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.
ubyte random[] = new ubyte[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.

Plattformen

Windows 98, Windows 2000 SP4, Windows CE, Windows Millennium Edition, Windows Mobile für Pocket PC, Windows Mobile für Smartphone, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition

.NET Framework unterstützt nicht alle Versionen sämtlicher Plattformen. Eine Liste der unterstützten Versionen finden Sie unter Systemanforderungen.

Versionsinformationen

.NET Framework

Unterstützt in: 2.0, 1.1, 1.0

.NET Compact Framework

Unterstützt in: 2.0

Siehe auch

Referenz

RandomNumberGenerator-Klasse
RandomNumberGenerator-Member
System.Security.Cryptography-Namespace

Weitere Ressourcen

Kryptografische Dienste