diff options
author | akr <akr@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2009-03-02 16:56:40 +0000 |
---|---|---|
committer | akr <akr@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2009-03-02 16:56:40 +0000 |
commit | 07291b4847a459d54f4eb75d3b073cda6eb5bd4c (patch) | |
tree | 5d3a14d64e1370299447b10a31116e21db3254f5 /lib | |
parent | 605572a099cd199dd08668c32fae94264d34e0a1 (diff) | |
download | ruby-07291b4847a459d54f4eb75d3b073cda6eb5bd4c.tar.gz ruby-07291b4847a459d54f4eb75d3b073cda6eb5bd4c.tar.xz ruby-07291b4847a459d54f4eb75d3b073cda6eb5bd4c.zip |
* lib/securerandom.rb (SecureRandom.urlsafe_base64): delete padding.
git-svn-id: http://svn.ruby-lang.org/repos/ruby/trunk@22713 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'lib')
-rw-r--r-- | lib/securerandom.rb | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/lib/securerandom.rb b/lib/securerandom.rb index b1477aa5b..6b16445bb 100644 --- a/lib/securerandom.rb +++ b/lib/securerandom.rb @@ -162,10 +162,12 @@ module SecureRandom # 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 "=". + # No padding is generated because "=" may be used as a URL delimiter. # - # p SecureRandom.urlsafe_base64 #=> "b4GOKm4pOYU_-BOXcrUGDg==" - # p SecureRandom.urlsafe_base64 #=> "UZLdOkzop70Ddx-IJR0ABg==" + # The result may contain A-Z, a-z, 0-9, "-" and "_". + # + # p SecureRandom.urlsafe_base64 #=> "b4GOKm4pOYU_-BOXcrUGDg" + # p SecureRandom.urlsafe_base64 #=> "UZLdOkzop70Ddx-IJR0ABg" # # If secure random number generator is not available, # NotImplementedError is raised. @@ -175,6 +177,7 @@ module SecureRandom s = [random_bytes(n)].pack("m*") s.delete!("\n") s.tr!("+/", "-_") + s.delete!("=") s end |