mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
securerandom.rb: [DOC] require in examples
* lib/securerandom.rb: added `require 'securerandom'` to each example, to state these methods are defined in this library and require it explicitly. [ruby-core:85933] [Bug #14576] [ci skip] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@63341 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
a99d017db7
commit
d32763eca0
1 changed files with 14 additions and 0 deletions
|
@ -119,6 +119,8 @@ module Random::Formatter
|
|||
#
|
||||
# The result may contain any byte: "\x00" - "\xff".
|
||||
#
|
||||
# require 'securerandom'
|
||||
#
|
||||
# p SecureRandom.random_bytes #=> "\xD8\\\xE0\xF4\r\xB2\xFC*WM\xFF\x83\x18\xF45\xB6"
|
||||
# p SecureRandom.random_bytes #=> "m\xDC\xFC/\a\x00Uf\xB2\xB2P\xBD\xFF6S\x97"
|
||||
#
|
||||
|
@ -139,6 +141,8 @@ module Random::Formatter
|
|||
#
|
||||
# The result may contain 0-9 and a-f.
|
||||
#
|
||||
# require 'securerandom'
|
||||
#
|
||||
# p SecureRandom.hex #=> "eb693ec8252cd630102fd0d0fb7c3485"
|
||||
# p SecureRandom.hex #=> "91dc3bfb4de5b11d029d376634589b61"
|
||||
#
|
||||
|
@ -158,6 +162,8 @@ module Random::Formatter
|
|||
#
|
||||
# The result may contain A-Z, a-z, 0-9, "+", "/" and "=".
|
||||
#
|
||||
# require 'securerandom'
|
||||
#
|
||||
# p SecureRandom.base64 #=> "/2BuBuLf3+WfSKyQbRcc/A=="
|
||||
# p SecureRandom.base64 #=> "6BbW0pxO0YENxn38HMUbcQ=="
|
||||
#
|
||||
|
@ -185,6 +191,8 @@ module Random::Formatter
|
|||
# The result may contain A-Z, a-z, 0-9, "-" and "_".
|
||||
# "=" is also used if _padding_ is true.
|
||||
#
|
||||
# require 'securerandom'
|
||||
#
|
||||
# p SecureRandom.urlsafe_base64 #=> "b4GOKm4pOYU_-BOXcrUGDg"
|
||||
# p SecureRandom.urlsafe_base64 #=> "UZLdOkzop70Ddx-IJR0ABg"
|
||||
#
|
||||
|
@ -204,6 +212,8 @@ module Random::Formatter
|
|||
|
||||
# SecureRandom.uuid generates a random v4 UUID (Universally Unique IDentifier).
|
||||
#
|
||||
# require 'securerandom'
|
||||
#
|
||||
# p SecureRandom.uuid #=> "2d931510-d99f-494a-8c67-87feb05e1594"
|
||||
# p SecureRandom.uuid #=> "bad85eb9-0713-4da7-8d36-07a8e4b00eab"
|
||||
# p SecureRandom.uuid #=> "62936e70-1815-439b-bf89-8492855a7e6b"
|
||||
|
@ -236,6 +246,8 @@ module Random::Formatter
|
|||
#
|
||||
# The result may contain whatever characters are in the source array.
|
||||
#
|
||||
# require 'securerandom'
|
||||
#
|
||||
# p SecureRandom.choose([*'l'..'r'], 16) #=> "lmrqpoonmmlqlron"
|
||||
# p SecureRandom.choose([*'0'..'9'], 5) #=> "27309"
|
||||
#
|
||||
|
@ -281,6 +293,8 @@ module Random::Formatter
|
|||
#
|
||||
# The result may contain A-Z, a-z and 0-9.
|
||||
#
|
||||
# require 'securerandom'
|
||||
#
|
||||
# p SecureRandom.alphanumeric #=> "2BuBuLf3WfSKyQbR"
|
||||
# p SecureRandom.alphanumeric(10) #=> "i6K93NdqiH"
|
||||
#
|
||||
|
|
Loading…
Reference in a new issue