tags:

views:

33

answers:

1

I have a problem with Ruby's openssl library.

Here is what I do:

In my Rails application, I start the "./script/console", then type:

>>OpenSSL::HMAC.hexdigest('sha256','','')

gives me this error:

TypeError: wrong argument (String)! (Expected kind of OpenSSL::Digest::Digest) from (irb):15:in `hexdigest' from (irb):15

I googled this error but couldn't get an answer on what's going on.

+2  A: 

The error message says you gave a string where an object of kind OpenSSL::Digest::Digest was expected.

So use OpenSSL::Digest::SHA256.new (which is an object of kind OpenSSL::Digest::Digest on account of SHA256 being a subclass of Digest) instead of 'sha256' (which is a string).

sepp2k