Method: Spider::SecureRandom.hex
- Defined in:
- lib/spiderfw/utils/secure_random.rb
.hex(n = nil) ⇒ Object
SecureRandom.hex generates a random hex string.
The argument n specifies the length of the random length. The length of the result string is twice of n.
If n is not specified, 16 is assumed. It may be larger in future.
If secure random number generator is not available, NotImplementedError is raised.
161 162 163 |
# File 'lib/spiderfw/utils/secure_random.rb', line 161 def self.hex(n=nil) random_bytes(n).unpack("H*")[0] end |