RandomNumberGenerator.GetBytes メソッド

定義

バイトの配列に、暗号的に強力なランダムな値シーケンスを格納します。

オーバーロード

名前 説明
GetBytes(Byte[])

派生クラスでオーバーライドされると、バイトの配列に暗号的に強力なランダムな値シーケンスを格納します。

GetBytes(Span<Byte>)

スパンに暗号的に強力なランダム バイトを格納します。

GetBytes(Byte[], Int32, Int32)

指定したバイト配列に、暗号的に強力なランダムな値シーケンスを入力します。

GetBytes(Byte[])

派生クラスでオーバーライドされると、バイトの配列に暗号的に強力なランダムな値シーケンスを格納します。

public:
 abstract void GetBytes(cli::array <System::Byte> ^ data);
public abstract void GetBytes(byte[] data);
abstract member GetBytes : byte[] -> unit
Public MustOverride Sub GetBytes (data As Byte())

パラメーター

data
Byte[]

暗号強度の高いランダム バイトで埋める配列。

次の例では、100 バイトのランダム シーケンスを作成し、 randomに格納します。

byte[] random = new byte[100];

using (RandomNumberGenerator rng = RandomNumberGenerator.Create())
{
    rng.GetBytes(random); // The array is now filled with cryptographically strong random bytes.
}
Dim random() As Byte = New Byte(100) {}
       
Using rng As RandomNumberGenerator = RandomNumberGenerator.Create()
   rng.GetBytes(random) ' bytes in random are now random
End Using

注釈

バイト配列の長さは、生成されるランダムバイトの数を決定します。

こちらもご覧ください

適用対象

GetBytes(Span<Byte>)

スパンに暗号的に強力なランダム バイトを格納します。

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

パラメーター

data
Span<Byte>

暗号強度の高いランダム バイトで埋めるスパン。

こちらもご覧ください

適用対象

GetBytes(Byte[], Int32, Int32)

指定したバイト配列に、暗号的に強力なランダムな値シーケンスを入力します。

public:
 virtual void GetBytes(cli::array <System::Byte> ^ data, int offset, int count);
public virtual void GetBytes(byte[] data, int offset, int count);
abstract member GetBytes : byte[] * int * int -> unit
override this.GetBytes : byte[] * int * int -> unit
Public Overridable Sub GetBytes (data As Byte(), offset As Integer, count As Integer)

パラメーター

data
Byte[]

暗号強度の高いランダム バイトで埋める配列。

offset
Int32

塗りつぶし操作を開始する配列のインデックス。

count
Int32

入力するバイト数。

例外

datanullです。

offset または count が 0 未満です

offset プラス countdataの長さを超えています。

適用対象