method
base64
v2_6_3 -
Show latest stable
-
0 notes -
Class: Formatter
- 1_8_6_287
- 1_8_7_72
- 1_8_7_330
- 1_9_1_378
- 1_9_2_180
- 1_9_3_125
- 1_9_3_392
- 2_1_10
- 2_2_9
- 2_4_6 (0)
- 2_5_5 (0)
- 2_6_3 (38)
- What's this?
base64(n=nil)
public
SecureRandom.base64 generates a random base64 string.
The argument n specifies the length, in bytes, of the random number to be generated. The length of the result string is about 4/3 of n.
If n is not specified or is nil, 16 is assumed. It may be larger in the future.
The result may contain A-Z, a-z, 0-9, “+”, “/” and “=”.
require 'securerandom' SecureRandom.base64 #=> "/2BuBuLf3+WfSKyQbRcc/A==" SecureRandom.base64 #=> "6BbW0pxO0YENxn38HMUbcQ=="
If a secure random number generator is not available, NotImplementedError is raised.
See RFC 3548 for the definition of base64.