Topic: Library not found for class Digest::SAM2 -- digest/sha2

I am new to ruby and rails and am trying to learn the infrastructure (obviously) and am using Agile Web Development with Rails (4th ed) to start with.

Using Rails 3.0.7 and Ruby 1.8.7

In attempting to encrypt a password + salt using the code:
  Digest::SHA2.hexdigest(password + 'wibble' + salt)

I get the error in the subject.
How do I tell rails where to find the library?  It exists in the proper directory in the Ruby install.

As a side question, what is the point of 'wibble' in thhe code?

Thanks in advance for any help.  -Fred

Last edited by fredrated (2011-08-16 12:16:11)

Re: Library not found for class Digest::SAM2 -- digest/sha2

try

require 'digest/sha'

I think digest/sha2 is depricated

Joe got a job, on the day shift, at the Utility Muffin Research Kitchen, arrogantly twisting the sterile canvas snout of a fully charged icing anointment utensil.

Re: Library not found for class Digest::SAM2 -- digest/sha2

Thanks for your reply.
My mistake: I should have mentioned that I placed require 'digest/sha2' at the top of my model .rb file.  When I change that to require 'digest/sha' I get "No such file to load -- digest/sha"
oh well...

Last edited by fredrated (2011-08-16 16:10:23)

Re: Library not found for class Digest::SAM2 -- digest/sha2

Sorry, that was a brain fart, 

C:\Documents and Settings\brad>irb
irb(main):001:0>
irb(main):002:0* require 'digest/sha2'
=> true
irb(main):003:0> require 'digest/sha1'
=> true

Try the above,  see if either one returns true

Joe got a job, on the day shift, at the Utility Muffin Research Kitchen, arrogantly twisting the sterile canvas snout of a fully charged icing anointment utensil.

Re: Library not found for class Digest::SAM2 -- digest/sha2

Both
require 'digest/sha2'
require 'digest/sha1'
return true.

However, the problem has stopped, don't know why.  Changed references in the model .rb file to lower case, ran the above commands, essentially twiddled the knobs because the problem continued when Voila! The error stopped!

Go figure.  Thanks for your help.

Re: Library not found for class Digest::SAM2 -- digest/sha2

Awesome!! It’s just what I need!! Thanks!..............


Daily Mashriq

Re: Library not found for class Digest::SAM2 -- digest/sha2

antishaz wrote:

Awesome!! It’s just what I need!! Thanks!..............


Daily Mashriq

hmm!!! he shear smart tips
_________________________
Dissertation Topic | Buy Dissertation

Re: Library not found for class Digest::SAM2 -- digest/sha2

thank you for sharing, It is a great post.

Ahmed faraz

Last edited by asadfaz (2012-05-17 06:46:36)

Re: Library not found for class Digest::SAM2 -- digest/sha2

Both
require 'digest/sha2'
require 'digest/sha1'
return false.

Not getting what to do. I got same problem as above.