mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
* lib/securerandom.rb (SecureRandom.urlsafe_base64): delete padding.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@22713 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
557359d170
commit
1c2005fbf6
2 changed files with 10 additions and 3 deletions
|
@ -1,3 +1,7 @@
|
||||||
|
Tue Mar 3 01:56:03 2009 Tanaka Akira <akr@fsij.org>
|
||||||
|
|
||||||
|
* lib/securerandom.rb (SecureRandom.urlsafe_base64): delete padding.
|
||||||
|
|
||||||
Mon Mar 2 21:39:08 2009 Tanaka Akira <akr@fsij.org>
|
Mon Mar 2 21:39:08 2009 Tanaka Akira <akr@fsij.org>
|
||||||
|
|
||||||
* ext/socket/sockport.h (SS_LEN): defined unconditionally.
|
* ext/socket/sockport.h (SS_LEN): defined unconditionally.
|
||||||
|
|
|
@ -162,10 +162,12 @@ module SecureRandom
|
||||||
# If n is not specified, 16 is assumed.
|
# If n is not specified, 16 is assumed.
|
||||||
# It may be larger in future.
|
# It may be larger in future.
|
||||||
#
|
#
|
||||||
# The result may contain A-Z, a-z, 0-9, "-", "_" and "=".
|
# No padding is generated because "=" may be used as a URL delimiter.
|
||||||
#
|
#
|
||||||
# p SecureRandom.urlsafe_base64 #=> "b4GOKm4pOYU_-BOXcrUGDg=="
|
# The result may contain A-Z, a-z, 0-9, "-" and "_".
|
||||||
# p SecureRandom.urlsafe_base64 #=> "UZLdOkzop70Ddx-IJR0ABg=="
|
#
|
||||||
|
# p SecureRandom.urlsafe_base64 #=> "b4GOKm4pOYU_-BOXcrUGDg"
|
||||||
|
# p SecureRandom.urlsafe_base64 #=> "UZLdOkzop70Ddx-IJR0ABg"
|
||||||
#
|
#
|
||||||
# If secure random number generator is not available,
|
# If secure random number generator is not available,
|
||||||
# NotImplementedError is raised.
|
# NotImplementedError is raised.
|
||||||
|
@ -175,6 +177,7 @@ module SecureRandom
|
||||||
s = [random_bytes(n)].pack("m*")
|
s = [random_bytes(n)].pack("m*")
|
||||||
s.delete!("\n")
|
s.delete!("\n")
|
||||||
s.tr!("+/", "-_")
|
s.tr!("+/", "-_")
|
||||||
|
s.delete!("=")
|
||||||
s
|
s
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue