157件ヒット
[1-100件を表示]
(0.059秒)
種類
- 特異メソッド (80)
- インスタンスメソッド (48)
- 文書 (17)
- モジュール (12)
ライブラリ
- ビルトイン (48)
- securerandom (92)
クラス
- Array (48)
モジュール
- SecureRandom (80)
キーワード
-
NEWS for Ruby 2
. 5 . 0 (8) -
NEWS for Ruby 3
. 0 . 0 (5) -
NEWS for Ruby 3
. 1 . 0 (4) - alphanumeric (8)
- base64 (12)
- hex (12)
-
random
_ bytes (12) -
random
_ number (12) - sample (48)
-
urlsafe
_ base64 (12) - uuid (12)
検索結果
先頭5件
-
SecureRandom (38180.0)
-
安全な乱数発生器のためのインターフェースを提供するモジュールです。 HTTP のセッションキーなどに適しています。
...するモジュールです。
HTTP のセッションキーなどに適しています。
以下の乱数発生器をサポートしています。
* openssl
* /dev/urandom
上の安全な乱数発生器が使用できない場合、各メソッドは NotImplementedError を発生します......adecimal string.
require 'securerandom'
p SecureRandom.hex(10) #=> "52750b30ffbc7de3b362"
p SecureRandom.hex(10) #=> "92b15d6c8dc4beb5f559"
p SecureRandom.hex(11) #=> "6aca1b5c58e4863e6b81b8"
p SecureRandom.hex(12) #=> "94b2fff3e7fd9b9c391a2306"
p SecureRandom.hex(13) #=> "39b290146bea6c......equire 'securerandom'
p SecureRandom.base64(10) #=> "EcmTPZwWRAozdA=="
p SecureRandom.base64(10) #=> "9b0nsevdwNuM/w=="
p SecureRandom.base64(10) #=> "KO1nIU+p9DKxGg=="
p SecureRandom.base64(11) #=> "l7XEiFja+8EKEtY="
p SecureRandom.base64(12) #=> "7kJSM/MzBJI+75j8"
p SecureRandom.base64... -
SecureRandom
. alphanumeric(n = nil) -> String (27130.0) -
ランダムな英数字を生成して返します。
...字を生成して返します。
@param n 生成される文字列のサイズを整数で指定します。
nil を指定した場合 n として 16 が使われます。
@return A-Z, a-z, 0-9 からなる文字列が返されます。
@raise NotImplementedError 安全な乱数発生器......が使えない場合に発生します。
//emlist[][ruby]{
require 'securerandom'
p SecureRandom.alphanumeric #=> "2BuBuLf3WfSKyQbR"
p SecureRandom.alphanumeric(10) #=> "i6K93NdqiH"
//}... -
SecureRandom
. urlsafe _ base64(n = nil , padding = false) -> String (21160.0) -
ランダムで URL-safe な base64 文字列を生成して返します。
...します。
@param n 文字列の生成に使われるランダムネスのサイズを整数で指定します。
生成される文字列のサイズはn の約 4/3 倍になります。
nil を指定した場合 n として 16 が使われます。
@param padding 真を指定......です。
@raise NotImplementedError 安全な乱数発生器が使えない場合に発生します。
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
. uuid -> String (21030.0) -
バージョン 4 の UUID (Universally Unique IDentifier) を生成して返します。
...味のある情報を含みません。
@raise NotImplementedError 安全な乱数発生器が使えない場合に発生します。
require 'securerandom'
p SecureRandom.uuid #=> "2d931510-d99f-494a-8c67-87feb05e1594"
p SecureRandom.uuid #=> "62936e70-1815-439b-bf89-8492855a7e6b"
@see... -
SecureRandom
. base64(n = nil) -> String (21018.0) -
ランダムな base64 文字列を生成して返します。
...ランダムな base64 文字列を生成して返します。
@param n 文字列の生成に使われるランダムネスのサイズを整数で指定します。
生成される文字列のサイズではないことに注意して下さい。生成される文字列のサイズは......3 倍になります。nil を指定した場合 n として 16 が使われます。
@raise NotImplementedError 安全な乱数発生器が使えない場合に発生します。
require 'securerandom'
p SecureRandom.base64(3) #=> "4pYO" (文字列のサイズは 3 でない)
@see 3548... -
SecureRandom
. hex(n = nil) -> String (21018.0) -
ランダムな hex 文字列を生成して返します。
...ランダムな hex 文字列を生成して返します。
@param n 文字列の生成に使われるランダムネスのサイズを整数で指定します。
生成される文字列のサイズではないことに注意して下さい。生成される文字列のサイズは......n の 2 倍になります。nil を指定した場合 n として 16 が使われます。
@raise NotImplementedError 安全な乱数発生器が使えない場合に発生します。
require 'securerandom'
p SecureRandom.hex(3) #=> "f72233" (文字列のサイズは 3 でない)... -
SecureRandom
. random _ bytes(n = nil) -> String (21018.0) -
ランダムなバイト列を生成して返します。
...。
@param n 生成される文字列のサイズを整数で指定します。
nil を指定した場合 n として 16 が使われます。
@raise NotImplementedError 安全な乱数発生器が使えない場合に発生します。
require 'securerandom'
p SecureRandom.random_by... -
SecureRandom
. random _ number(n = 0) -> Integer | Float (21018.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) #=> 4078466195356651... -
Array
# sample -> object | nil (6148.0) -
配列の要素を1個(引数を指定した場合は自身の要素数を越えない範囲で n 個) ランダムに選んで返します。
...。
配列が空の場合、無引数の場合は nil を、個数を指定した場合は空配列を返します。
srand()が有効です。
@param n 取得する要素の数を指定します。自身の要素数(self.length)以上の
値を指定した場合は要素数と同じ数......。
整数以外のオブジェクトを指定した場合は to_int メソッドによる暗
黙の型変換を試みます。
@param random 乱数生成器(主に Random オブジェクト)を指定します。
選択する要素のインデックスを返す rand.......to_a
p a.sample #=> 9
p a.sample #=> 10
p a.sample(3) #=> [1, 9, 3]
p a #=> [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
//}
random SecureRandom などの乱数生成器を渡すことができます。
//emlist[例][ruby]{
require 'securerandom'
a = (1..10).to_a
p a.sample(ra...