altcha-org / altcha

GDPR compliant, self-hosted CAPTCHA alternative with PoW mechanism and advanced anti-spam filter.
https://altcha.org
MIT License
509 stars 17 forks source link

RuntimeError (Unsupported digest algorithm (SHA-256).: first num too large) #44

Closed kowo-zahl closed 4 months ago

kowo-zahl commented 4 months ago

Hi,

on my development server, the gem works fine, but on my production server I got the following error:

RuntimeError (Unsupported digest algorithm (SHA-256).: first num too large)

It seems there is some trouble with the name SHA-256

When I change line

  a.signature = OpenSSL::HMAC.hexdigest(OpenSSL::Digest.new(a.algorithm), Altcha.hmac_key, a.challenge)

to
a.signature = OpenSSL::HMAC.hexdigest(OpenSSL::Digest::SHA256.new, Altcha.hmac_key, a.challenge)

in altcha-rails.rb it works fine.

ovx commented 4 months ago

Hi, the problem is with the name, in JavaScript, the names contain dashes, but in Ruby, you have to use names without dashes (docs) so you'll have normalize the name before creating a digest.

ovx commented 4 months ago

Closing due to inactivity.