Rails SHA1 issue

Rails SHA1 issue

Posted by: garrett
Posted on: 2005-08-24 09:37:00

Has anyone used the SHA1 hash in Rails on DH? I can't get it to work. In my code:

Digest::SHA1.hexdigest(password)

Causes an "Application Error (Rails)", and I see this in the log:

NameError (uninitialized constant SHA1):
/usr/lib/ruby/gems/1.8/gems/activesupport-1.1.1/lib/active_support/dependencies.rb:186:in `const_missing'
/app/models/author.rb:31:in `hash_password'
/app/controllers/author_controller.rb:84:in `do_login'
/usr/lib/ruby/gems/1.8/gems/actionpack-1.9.1/lib/action_controller/base.rb:756:in `send'
/usr/lib/ruby/gems/1.8/gems/actionpack-1.9.1/lib/action_controller/base.rb:756:in `perform_action_without_filters'
/usr/lib/ruby/gems/1.8/gems/actionpack-1.9.1/lib/action_controller/filters.rb:295:in `perform_action_without_benchmark'
/usr/lib/ruby/gems/1.8/gems/actionpack-1.9.1/lib/action_controller/benchmarking.rb:41:in `perform_action_without_rescue'
/usr/lib/ruby/gems/1.8/gems/actionpack-1.9.1/lib/action_controller/benchmarking.rb:41:in `measure'
/usr/lib/ruby/gems/1.8/gems/actionpack-1.9.1/lib/action_controller/benchmarking.rb:41:in `perform_action_without_rescue'
/usr/lib/ruby/gems/1.8/gems/actionpack-1.9.1/lib/action_controller/rescue.rb:80:in `perform_action'
/usr/lib/ruby/gems/1.8/gems/actionpack-1.9.1/lib/action_controller/base.rb:356:in `send'
/usr/lib/ruby/gems/1.8/gems/actionpack-1.9.1/lib/action_controller/base.rb:356:in `process'
/usr/lib/ruby/gems/1.8/gems/rails-0.13.1/lib/dispatcher.rb:32:in `dispatch'
/usr/lib/ruby/gems/1.8/gems/rails-0.13.1/lib/fcgi_handler.rb:144:in `process_request'
/usr/lib/ruby/gems/1.8/gems/rails-0.13.1/lib/fcgi_handler.rb:64:in `process!'
/usr/lib/ruby/gems/1.8/gems/rails-0.13.1/lib/fcgi_handler.rb:55:in `each_cgi'
/usr/lib/ruby/1.8/fcgi.rb:597:in `each'
/usr/lib/ruby/1.8/fcgi.rb:597:in `each_cgi'
/usr/lib/ruby/gems/1.8/gems/rails-0.13.1/lib/fcgi_handler.rb:55:in `process!'
/usr/lib/ruby/gems/1.8/gems/rails-0.13.1/lib/fcgi_handler.rb:21:in `process!'
dispatch.fcgi:24

Digest is part of the Ruby standard lib, so this should work with no trouble. Anyone know what's going on here?

Re: Rails SHA1 issue

Posted by: garrett
Posted on: 2005-08-24 19:21:00

anyone know how i can include the Digest::SHA1 method on my own so this works?

Re: Rails SHA1 issue

Posted by: twilcoxen
Posted on: 2005-08-25 20:42:00

Try this:

  require 'digest/sha1'

That's working for me.

-Tom Wilcoxen
convergent arts

Tags: libgemsfcgiusrrubyactionhashcgipassworddispatcherconstbenchmarkdispatch