LoginSignup
0
0

More than 3 years have passed since last update.

乱数アルゴリズムの試用ツールとしてのStreamRelay.NET.exe

Last updated at Posted at 2017-06-21

いくつかの乱数アルゴリズムをお試しする事ができる


乱数アルゴリズムの一覧

StreamRelay.NET.exe -ListRandomize

一例だとこんな感じ

C:>StreamRelay.NET.exe -ListRandomize


Randomize is
Random :System.Random
CryptoRandom :System.Security.Cryptography.RNGCryptoServiceProvider
MT :Mersenne Twister (Meisui.Random)
PBKDF1 :System.Security.Cryptography.PasswordDeriveBytes
PBKDF2/// :System.Security.Cryptography.Rfc2898DeriveBytes
NoRandom :Increment(NoRandom)
BouncyCastleRandom :SecureRandom(Org.BouncyCastle.Security.SecureRandom) (
BouncyCastle.Crypto.dll)
BC_VmpcRandom :VmpcRandom (BouncyCastle.Crypto.dll)
CmdRandom :CmdRandom (Environment(cmd.exe) RANDOM
MersenneTwister :MersenneTwister (Rei.Random.dll)
SFMT :SFMT (Rei.Random.dll)
LCG :LCG (Rei.Random.dll)
MotherOfAll :MotherOfAll (Rei.Random.dll)
RanrotB :RanrotB (Rei.Random.dll)
XorShift :XorShift (Rei.Random.dll)
Well :Well (Rei.Random.dll)
RAND :rand (Win32 API)
RAND_S :rand_s(Win32 API)
RdRand :RdRand(use Intel CPU{Ivy Bridge})


乱数アルゴリズムの試用ツールとしてのStreamRelay.NET.exe

-ListRndNumber で乱数の範囲とアルゴリズムを決めて、-ListRndNumberCount で回数を決める

StreamRelay.NET.exe -ListRndNumber 3-100,Random -ListRndNumber 3-100,CryptoRandom -ListRndNumberCount 20

だと、最小値=3、最大値=100の間で、アルゴリズムは「Random」と「CryptoRandom」で20回実行する。

という意味になる

こんな感じ

C:>StreamRelay.NET.exe -ListRndNumber 3-100,Random -ListRndNumber 3-100,CryptoRandom -ListRndNumberCount 20
,Random,CryptoRandom
, 40 85
, 58 89
, 41 95
, 34 32
, 5 27
, 45 29
, 3 84
, 62 15
, 97 4
, 19 74
, 4 59
, 4 34
, 95 3
, 85 13
, 15 12
, 93 35
, 13 66
, 27 17
, 91 91
, 29 81


実行時間(-Verbsoe)

-Verbose つけると実行時間を表示する

こんな感じ

C:>StreamRelay.NET.exe -ListRndNumber 3-100,Random -ListRndNumber 3-100,CryptoRandom -ListRndNumberCount 20 -verbose
1970/01/01 13:39:29

,Random,CryptoRandom
, 53 39
, 94 85
, 81 46
, 71 31
, 26 42
, 8 48
, 23 31
, 97 72
, 28 47
, 62 64
, 7 66
, 22 62
, 10 4
, 55 74
, 40 62
, 39 78
, 40 94
, 33 4
, 36 4
, 88 56
1970/01/01 13:39:29

0.0312sec
31.2ms


アルゴリズムの説明

Random
.NET Framework標準のSystem.Randomクラス
CryptoRandom
.NET Framework標準のSystem.Security.Cryptography.RNGCryptoServiceProviderクラス
NoRandom
これは、最小値から+1ずつしていくので、乱数ではないよ
PBKDF1
.NET Framework標準のパスワード攪拌のSystem.Security.Cryptography.PasswordDeriveBytesクラスを乱数のように呼び出してみた
PBKDF2/"PasswordHex"/"SaltHex"/"Interaction"
.NET Framework標準のパスワード攪拌のSystem.Security.Cryptography.Rfc2898DeriveBytesクラスを乱数のように呼び出してみた
RdRand
Intel CPUのIvy Bridge以降のハードウェア乱数器RdRand (Win32\Plugin.RdRand.x86.dll と Win64\Plugin.RdRand.x64.dll と RdRandLib.dll で実装されている)
RAND
Win32APIのrand()をVC++/CLI経由で呼び出してみた。(Win32\CRandom32.dll と Win64\CRandom64.dll で実装されている)
RAND_S
Win32APIのrand_s()をVC++/CLI経由で呼び出してみた。(Win32\CRandom32.dll と Win64\CRandom64.dll で実装されている)
MT
Mersenne Twister (Meisui.Random)
BouncyCastleRandom
SecureRandom(Org.BouncyCastle.Security.SecureRandomクラス) (BouncyCastle.Crypto.dll を Plugin.BouncyCastle.Crypto.dll 経由で呼び出し)
BC_VmpcRandom
VmpcRandomGenerator(Org.BouncyCastle.Crypto.Prng.VmpcRandomGeneratorクラス) (BouncyCastle.Crypto.dll を Plugin.BouncyCastle.Crypto.dll 経由で呼び出し)
MersenneTwister
Rei.Random.dll を Plugin.Rei.Random.dll経由で呼び出し
SFMT
Rei.Random.dll を Plugin.Rei.Random.dll経由で呼び出し
LCG
Rei.Random.dll を Plugin.Rei.Random.dll経由で呼び出し
MotherOfAll
Rei.Random.dll を Plugin.Rei.Random.dll経由で呼び出し
RanrotB
Rei.Random.dll を Plugin.Rei.Random.dll経由で呼び出し
XorShift
Rei.Random.dll を Plugin.Rei.Random.dll経由で呼び出し
Well
Rei.Random.dll を Plugin.Rei.Random.dll経由で呼び出し
CmdRandom
cmd.exe の環境変数RANDOMの値。秒がシードなのかすばやく実行すると同じ値が連続するよ。Plugin.CmdRandom.dll に実装した

目次へ戻る

目次というか最初の一歩

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0