RandomNumberGenerator.GetBytes メソッド

定義

バイト配列に、暗号化に使用する値の厳密なランダム シーケンスを設定します。

オーバーロード

GetBytes(Span<Byte>)

暗号強度の高いランダム バイトをスパンに格納します。

GetBytes(Byte[], Int32, Int32)

指定したバイト配列に、暗号化に使用するランダムな値の厳密なシーケンスを設定します。

GetBytes(Byte[])

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

GetBytes(Int32)

暗号的に強力なランダムな値シーケンスを持つバイト配列を作成します。

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 未満です。

offsetcount の合計が data の長さを超えています。

適用対象

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格納します。

array<Byte>^ random = gcnew array<Byte>(100);

//RNGCryptoServiceProvider is an implementation of a random number generator.
RNGCryptoServiceProvider^ rng = gcnew RNGCryptoServiceProvider;
rng->GetBytes( random ); // The array is now filled with cryptographically strong random bytes.
byte[] random = new Byte[100];

//RNGCryptoServiceProvider is an implementation of a random number generator.
RNGCryptoServiceProvider rng = new RNGCryptoServiceProvider();
rng.GetBytes(random); // The array is now filled with cryptographically strong random bytes.
Dim random() As Byte = New Byte(100) {}
       
'RNGCryptoServiceProvider is an implementation of an RNG
Dim rng As New RNGCryptoServiceProvider()
rng.GetBytes(random) ' bytes in random are now random

注釈

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

こちらもご覧ください

適用対象

GetBytes(Int32)

暗号的に強力なランダムな値シーケンスを持つバイト配列を作成します。

public:
 static cli::array <System::Byte> ^ GetBytes(int count);
public static byte[] GetBytes (int count);
static member GetBytes : int -> byte[]
Public Shared Function GetBytes (count As Integer) As Byte()

パラメーター

count
Int32

作成するランダムな値のバイト数。

戻り値

Byte[]

暗号的に強力なランダム値が設定された配列。

例外

count が 0 未満です。

適用対象