method

base64

Importance_1
Ruby latest stable (v2_5_5) - 0 notes - Class: SecureRandom

Method deprecated or moved

This method is deprecated or moved on the latest stable version. The last existing version (v2_2_9) is shown here.

These similar methods exist in v2_5_5:

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 future.

The result may contain A-Z, a-z, 0-9, “+”, “/” and “=”.

p SecureRandom.base64 #=> "/2BuBuLf3+WfSKyQbRcc/A=="
p SecureRandom.base64 #=> "6BbW0pxO0YENxn38HMUbcQ=="

If secure random number generator is not available, NotImplementedError is raised.

See RFC 3548 for the definition of base64.

Show source
Register or log in to add new notes.