base64

base64(n=nil)
Class Public methods

::base64 generates a random base64 string.

The argument n specifies the length of the random length. The length of the result string is about 4/3 of n.

If n is not specified, 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.

doc_ruby_on_rails
2015-05-14 05:45:51
Comments
Leave a Comment

Please login to continue.