Module: QuoVadis::Hmacable
- Included in:
- Totp
- Defined in:
- lib/quo_vadis/hmacable.rb
Instance Method Summary collapse
Instance Method Details
#compute_hmac(data) ⇒ Object
10 11 12 |
# File 'lib/quo_vadis/hmacable.rb', line 10 def compute_hmac(data) OpenSSL::HMAC.hexdigest 'SHA256', hmac_secret, data end |
#timing_safe_eql?(provided, actual) ⇒ Boolean
14 15 16 17 |
# File 'lib/quo_vadis/hmacable.rb', line 14 def timing_safe_eql?(provided, actual) provided = provided.to_s Rack::Utils.secure_compare(provided.ljust(actual.length), actual) && provided.length == actual.length end |