Permalink
Browse files

Updated securerandom.rb to 1.9.3p0.

  • Loading branch information...
1 parent 2614b15 commit 3a579b7abd28b101f9ab3663fbfcd69c395910f1 @brixen brixen committed Nov 22, 2011
Showing with 13 additions and 13 deletions.
  1. +13 −13 lib/19/securerandom.rb
@@ -41,9 +41,9 @@
module SecureRandom
# SecureRandom.random_bytes generates a random binary string.
#
- # The argument n specifies the length of the result string.
+ # The argument _n_ specifies the length of the result string.
#
- # If n is not specified, 16 is assumed.
+ # If _n_ is not specified, 16 is assumed.
# It may be larger in future.
#
# The result may contain any byte: "\x00" - "\xff".
@@ -57,7 +57,7 @@ def self.random_bytes(n=nil)
n ||= 16
if defined? OpenSSL::Random
- @pid = $$ if !defined?(@pid)
+ @pid = 0 if !defined?(@pid)
pid = $$
if @pid != pid
now = Time.now
@@ -123,10 +123,10 @@ def self.random_bytes(n=nil)
# 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.
+ # 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.
+ # If _n_ is not specified, 16 is assumed.
# It may be larger in future.
#
# The result may contain 0-9 and a-f.
@@ -142,10 +142,10 @@ def self.hex(n=nil)
# SecureRandom.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.
+ # 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.
+ # 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 "=".
@@ -156,7 +156,7 @@ def self.hex(n=nil)
# If secure random number generator is not available,
# NotImplementedError is raised.
#
- # See RFC 3548 for base64.
+ # See RFC 3548 for the definition of base64.
def self.base64(n=nil)
[random_bytes(n)].pack("m*").delete("\n")
end
@@ -186,7 +186,7 @@ def self.base64(n=nil)
# If secure random number generator is not available,
# NotImplementedError is raised.
#
- # See RFC 3548 for URL-safe base64.
+ # See RFC 3548 for the definition of URL-safe base64.
def self.urlsafe_base64(n=nil, padding=false)
s = [random_bytes(n)].pack("m*")
s.delete!("\n")
@@ -197,15 +197,15 @@ def self.urlsafe_base64(n=nil, padding=false)
# SecureRandom.random_number generates a random number.
#
- # If an positive integer is given as n,
+ # If a positive integer is given as _n_,
# SecureRandom.random_number returns an integer:
# 0 <= SecureRandom.random_number(n) < n.
#
# p SecureRandom.random_number(100) #=> 15
# p SecureRandom.random_number(100) #=> 88
#
# If 0 is given or an argument is not given,
- # SecureRandom.random_number returns an float:
+ # SecureRandom.random_number returns a float:
# 0.0 <= SecureRandom.random_number() < 1.0.
#
# p SecureRandom.random_number #=> 0.596506046187744

0 comments on commit 3a579b7

Please sign in to comment.