RNGCryptoServiceProvider.GetBytes メソッド
バイト配列に、暗号化に使用する厳密な値のランダム シーケンスを設定します。
Overrides Public Sub GetBytes( _
ByVal data() As Byte _)
[C#]
public override void GetBytes(byte[] data);
[C++]
public: void GetBytes(unsigned chardata __gc[]);
[JScript]
public override function GetBytes(
data : Byte[]);
パラメータ
- data
暗号化に使用する厳密なランダム バイトを格納する配列。
例外
例外の種類 | 条件 |
---|---|
CryptographicException | 暗号サービス プロバイダ (CSP) を取得できません。 |
解説
バイト配列の長さによって、生成される暗号的に厳密なランダム バイト数が決まります。
使用例
[Visual Basic, C#, C++] 100 バイト長のランダム シーケンスを作成し、 random
に格納する例を次に示します。
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
[C#]
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.
[C++]
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.
[JScript] JScript のサンプルはありません。Visual Basic、C#、および C++ のサンプルを表示するには、このページの左上隅にある言語のフィルタ ボタン をクリックします。
必要条件
プラットフォーム: Windows 98, Windows NT 4.0, Windows Millennium Edition, Windows 2000, Windows XP Home Edition, Windows XP Professional, Windows Server 2003 ファミリ
参照
RNGCryptoServiceProvider クラス | RNGCryptoServiceProvider メンバ | System.Security.Cryptography 名前空間 | 暗号サービス