ライブラリ
- ビルトイン (156)
- matrix (24)
-
minitest
/ unit (1) - objspace (12)
- openssl (132)
- securerandom (92)
- timeout (21)
-
webrick
/ utils (12)
クラス
- Array (48)
- Matrix (24)
-
MiniTest
:: Unit :: TestCase (1) -
OpenSSL
:: PKey :: DSA (24) -
OpenSSL
:: PKey :: EC (12) -
OpenSSL
:: PKey :: RSA (24) - Random (48)
モジュール
- Enumerable (48)
- ObjectSpace (12)
-
OpenSSL
:: Random (72) - SecureRandom (80)
- Timeout (21)
-
WEBrick
:: Utils (12)
キーワード
- DEFAULT (9)
-
NEWS for Ruby 2
. 0 . 0 (12) -
NEWS for Ruby 2
. 5 . 0 (8) -
NEWS for Ruby 2
. 6 . 0 (7) -
NEWS for Ruby 3
. 0 . 0 (5) -
NEWS for Ruby 3
. 1 . 0 (4) - SecureRandom (12)
- alphanumeric (8)
- base64 (12)
- build (24)
- bytes (7)
-
count
_ tdata _ objects (12) - egd (12)
-
egd
_ bytes (12) - generate (48)
- hex (12)
-
load
_ random _ file (12) -
marshal
_ dump (12) -
max
_ by (48) -
pseudo
_ bytes (12) -
public
_ key? (12) -
random
_ bytes (12) -
random
_ number (12) -
random
_ string (12) - securerandom (12)
- shuffle (24)
- shuffle! (24)
- srand (12)
- status? (12)
-
test
/ unit (1) -
test
_ methods (1) - timeout (21)
- urandom (8)
-
urlsafe
_ base64 (12) - uuid (12)
-
write
_ random _ file (12)
検索結果
先頭5件
-
Random (38006.0)
-
MT19937に基づく擬似乱数生成器を提供するクラスです。
...MT19937に基づく擬似乱数生成器を提供するクラスです。
=== 参考
オリジナル版 http://www.math.sci.hiroshima-u.ac.jp/~m-mat/MT/mt.html... -
Random
. urandom(size) -> String (33212.0) -
プラットフォームの提供する機能を使って、文字列を返します。
...します。
@return 返り値はバイナリ形式で、暗号的に安全な擬似乱数だと期待できます。
@raise RuntimeError プラットフォームの提供する機能の準備に失敗した場合に発生します。
2017年の時点で、Linuxのmanpage(random(7))には「今日......る暗号化プリミティブが入手可能だとは期待できません」と
書いてあります。そのため、sizeとして32より大きい値を指定することには疑問の
余地があります。
//emlist[例][ruby]{
Random.urandom(8) #=> "\x78\x41\xBA\xAF\x7D\xEA\xD8\xEA"
//}... -
Random
:: DEFAULT -> Random (27229.0) -
Ruby 3.0 から非推奨で,3.2で廃止されます。代わりに Random クラスオブジェクトを擬似乱数生成器として使用してください。
...Ruby 3.0 から非推奨で,3.2で廃止されます。代わりに Random クラスオブジェクトを擬似乱数生成器として使用してください。
デフォルトの擬似乱数生成器です。
Random.rand や Kernel.#rand などで使用されます。
@see Random.srand, Kern... -
Random
:: DEFAULT -> Class (27146.0) -
Ruby 3.0 から非推奨で,3.2で廃止されます。代わりに Random クラスオブジェクトを擬似乱数生成器として使用してください。
...Ruby 3.0 から非推奨で,3.2で廃止されます。代わりに Random クラスオブジェクトを擬似乱数生成器として使用してください。
また、 Random::DEFAULT は Random クラスオブジェクトが返ります。
//emlist[][ruby]{
Random::DEFAULT == Random # =>......true
Random.rand(10) # => 4
//}... -
Random
# marshal _ dump -> Array (27128.0) -
Random#marshal_load で復元可能な配列を返します。
...Random#marshal_load で復元可能な配列を返します。
//emlist[例][ruby]{
r1 = Random.new(1)
a1 = r1.marshal_dump
r2 = Random.new(3)
p r1 == r2 # => false
r3 = r2.marshal_load(a1)
p r1 == r2 # => true
p r1 == r3 # => true
//}... -
Random
. srand(number) -> Integer (21106.0) -
デフォルトの擬似乱数生成器の種を設定し、古い種を返します。 Kernel.#srand と同じです。
...デフォルトの擬似乱数生成器の種を設定し、古い種を返します。
Kernel.#srand と同じです。
@param number 擬似乱数発生器の種を整数で指定します。
@see Kernel.#rand, Random::DEFAULT......デフォルトの擬似乱数生成器の種を設定し、古い種を返します。
Kernel.#srand と同じです。
@param number 擬似乱数発生器の種を整数で指定します。
@see Kernel.#rand... -
Random
. bytes(size) -> String (21018.0) -
ランダムなバイナリー文字列を返します。結果の文字列のサイズを指定できます。
...ランダムなバイナリー文字列を返します。結果の文字列のサイズを指定できます。
@param size 結果の文字列のサイズをバイト数で指定します。
//emlist[][ruby]{
Random.bytes(10) # => "\xAC\n\x7F\x8C/\xAA\xC4\x97u\xA6"
//}
@see Random#bytes... -
SecureRandom
. random _ number(n = 0) -> Integer | Float (15207.0) -
ランダムな数値を生成して返します。 n が 1 以上の整数の場合、0 以上 n 未満の整数を返します。 n が 0 の場合、0.0 以上 1.0 未満の実数を返します。
...1.0 未満の実数を返します。
@param n ランダムな数値の上限を数値で指定します。
@raise NotImplementedError 安全な乱数発生器が使えない場合に発生します。
require 'securerandom'
p SecureRandom.random_number(1 << 64) #=> 4078466195356651249... -
SecureRandom
. random _ bytes(n = nil) -> String (12107.0) -
ランダムなバイト列を生成して返します。
...字列のサイズを整数で指定します。
nil を指定した場合 n として 16 が使われます。
@raise NotImplementedError 安全な乱数発生器が使えない場合に発生します。
require 'securerandom'
p SecureRandom.random_bytes(3) #=> "\321\020\203"... -
SecureRandom
. urlsafe _ base64(n = nil , padding = false) -> String (12100.0) -
ランダムで URL-safe な base64 文字列を生成して返します。
...ランダムで URL-safe な base64 文字列を生成して返します。
@param n 文字列の生成に使われるランダムネスのサイズを整数で指定します。
生成される文字列のサイズはn の約 4/3 倍になります。
nil を指定した場合 n......require 'securerandom'
p SecureRandom.urlsafe_base64 #=> "b4GOKm4pOYU_-BOXcrUGDg"
p SecureRandom.urlsafe_base64 #=> "UZLdOkzop70Ddx-IJR0ABg"
p SecureRandom.urlsafe_base64(nil, true) #=> "i0XQ-7gglIsHGV2_BNPrdQ=="
p SecureRandom.urlsafe_base64(nil, true) #=> "-M8rLhr7JEpJlqFGUMmOxg==......"
@see SecureRandom.base64, 3548... -
SecureRandom (12036.0)
-
安全な乱数発生器のためのインターフェースを提供するモジュールです。 HTTP のセッションキーなどに適しています。
.../urandom
上の安全な乱数発生器が使用できない場合、各メソッドは NotImplementedError を発生します。
# random hexadecimal string.
require 'securerandom'
p SecureRandom.hex(10) #=> "52750b30ffbc7de3b362"
p SecureRandom.hex(10) #=> "92b15d6c8dc4beb5f559"
p Secu......reRandom.hex(11) #=> "6aca1b5c58e4863e6b81b8"
p SecureRandom.hex(12) #=> "94b2fff3e7fd9b9c391a2306"
p SecureRandom.hex(13) #=> "39b290146bea6ce975c37cfc23"
# random base64 string.
require 'securerandom'
p SecureRandom.base64(10) #=> "EcmTPZwWRAozdA=="
p SecureRandom.base64(10) #=> "9b0n......evdwNuM/w=="
p SecureRandom.base64(10) #=> "KO1nIU+p9DKxGg=="
p SecureRandom.base64(11) #=> "l7XEiFja+8EKEtY="
p SecureRandom.base64(12) #=> "7kJSM/MzBJI+75j8"
p SecureRandom.base64(13) #=> "vKLJ0tXBHqQOuIcSIg=="
# random binary string.
require 'securerandom'
p SecureRandom.random_byt...