Ruby 4.0 リファレンスマニュアル

singleton method SecureRandom.bytes

bytes(n) -> StringRuby 2.4.0 から[permalink][rdoc][edit]

n バイトの乱数を生成し、バイナリの文字列として返します。

[PARAM] n:
生成する文字列のバイト数を整数で指定します。
[EXCEPTION] NotImplementedError:
安全な乱数発生器が使えない場合に発生します。
require 'securerandom'
p SecureRandom.bytes(10) # => "\"\xCD\x9E\xE0\x9C0\xEF\xB2I\xAB"

[SEE_ALSO] SecureRandom.random_bytes