RandomNumberGenerator.GetNonZeroBytes 方法

定义

重载

GetNonZeroBytes(Byte[])

当在派生类中重写时,用加密型强随机非零值序列填充字节数组。

GetNonZeroBytes(Span<Byte>)

使用加密型强随机非零值序列填充字节范围。

GetNonZeroBytes(Byte[])

Source:
RandomNumberGenerator.cs
Source:
RandomNumberGenerator.cs
Source:
RandomNumberGenerator.cs

当在派生类中重写时,用加密型强随机非零值序列填充字节数组。

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

参数

data
Byte[]

用加密型强随机非零字节填充的数组。

示例

以下示例创建一个包含 100 个非零字节的随机序列,并将其存储在 中 random

array<Byte>^ random = gcnew array<Byte>(100);
RandomNumberGenerator^ rng = RandomNumberGenerator::Create();
rng->GetNonZeroBytes( random ); // The array is now filled with cryptographically strong random bytes, and none are zero.
byte[] random = new byte[100];

using (RandomNumberGenerator rng = RandomNumberGenerator.Create())
{
    rng.GetNonZeroBytes(random); // The array is now filled with cryptographically strong random bytes, and none are zero.
}
Dim random() As Byte = New Byte(100) {}

Using rng As RandomNumberGenerator = RandomNumberGenerator.Create()
    rng.GetNonZeroBytes(random) ' bytes in random are now random and none are zero
End Using

注解

字节数组的长度决定了生成的随机字节数。

另请参阅

适用于

GetNonZeroBytes(Span<Byte>)

Source:
RandomNumberGenerator.cs
Source:
RandomNumberGenerator.cs
Source:
RandomNumberGenerator.cs

使用加密型强随机非零值序列填充字节范围。

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

参数

data
Span<Byte>

要用加密型强随机非零字节填充的范围。

适用于