[前][次][番号順一覧][スレッド一覧]

ruby-changes:11114

From: akr <ko1@a...>
Date: Tue, 3 Mar 2009 01:57:09 +0900 (JST)
Subject: [ruby-changes:11114] Ruby:r22713 (trunk): * lib/securerandom.rb (SecureRandom.urlsafe_base64): delete padding.

akr	2009-03-03 01:56:40 +0900 (Tue, 03 Mar 2009)

  New Revision: 22713

  http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=22713

  Log:
    * lib/securerandom.rb (SecureRandom.urlsafe_base64): delete padding.

  Modified files:
    trunk/ChangeLog
    trunk/lib/securerandom.rb

Index: ChangeLog
===================================================================
--- ChangeLog	(revision 22712)
+++ ChangeLog	(revision 22713)
@@ -1,3 +1,7 @@
+Tue Mar  3 01:56:03 2009  Tanaka Akira  <akr@f...>
+
+	* lib/securerandom.rb (SecureRandom.urlsafe_base64): delete padding.
+
 Mon Mar  2 21:39:08 2009  Tanaka Akira  <akr@f...>
 
 	* ext/socket/sockport.h (SS_LEN): defined unconditionally.
Index: lib/securerandom.rb
===================================================================
--- lib/securerandom.rb	(revision 22712)
+++ lib/securerandom.rb	(revision 22713)
@@ -162,11 +162,13 @@
   # 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 @@
     s = [random_bytes(n)].pack("m*")
     s.delete!("\n")
     s.tr!("+/", "-_")
+    s.delete!("=")
     s
   end
 

--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]