mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
* lib/cgi/session.rb: use secrand for generating cookies.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@12476 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
94fdd87fdd
commit
b1cd416c1a
2 changed files with 17 additions and 9 deletions
|
@ -2,6 +2,8 @@ Fri Jun 8 14:26:18 2007 Tanaka Akira <akr@fsij.org>
|
||||||
|
|
||||||
* lib/secrand.rb: new file for secure random interface.
|
* lib/secrand.rb: new file for secure random interface.
|
||||||
|
|
||||||
|
* lib/cgi/session.rb: use secrand for generating cookies.
|
||||||
|
|
||||||
Fri Jun 8 12:44:37 2007 NAKAMURA Usaku <usa@ruby-lang.org>
|
Fri Jun 8 12:44:37 2007 NAKAMURA Usaku <usa@ruby-lang.org>
|
||||||
|
|
||||||
* {win32,wince}/Makefile.sub: add lex.c rule.
|
* {win32,wince}/Makefile.sub: add lex.c rule.
|
||||||
|
|
|
@ -174,16 +174,22 @@ class CGI
|
||||||
# is used internally for automatically generated
|
# is used internally for automatically generated
|
||||||
# session ids.
|
# session ids.
|
||||||
def create_new_id
|
def create_new_id
|
||||||
require 'digest/md5'
|
require 'secrand'
|
||||||
md5 = Digest::MD5::new
|
begin
|
||||||
now = Time::now
|
session_id = SecRand.hex(16)
|
||||||
md5.update(now.to_s)
|
rescue NotImplementedError
|
||||||
md5.update(String(now.usec))
|
require 'digest/md5'
|
||||||
md5.update(String(rand(0)))
|
md5 = Digest::MD5::new
|
||||||
md5.update(String($$))
|
now = Time::now
|
||||||
md5.update('foobar')
|
md5.update(now.to_s)
|
||||||
|
md5.update(String(now.usec))
|
||||||
|
md5.update(String(rand(0)))
|
||||||
|
md5.update(String($$))
|
||||||
|
md5.update('foobar')
|
||||||
|
session_id = md5.hexdigest[0,16]
|
||||||
|
end
|
||||||
@new_session = true
|
@new_session = true
|
||||||
md5.hexdigest[0,16]
|
session_id
|
||||||
end
|
end
|
||||||
private :create_new_id
|
private :create_new_id
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue