Reputation: 8172
I need to convert this php function to Rails. It is used to encrypt the data we supply with a special key. The output of this function should match the ruby function. Please help.
public static function genHash($secret, $data) {
$ourhash = hash_hmac('sha256', utf8_decode($data), utf8_decode($secret), FALSE);
return $Hmac;
}
Upvotes: 5
Views: 2888
Reputation: 66
require 'openssl'
def genHash(secret, data)
OpenSSL::HMAC.hexdigest('sha256', secret, data)
end
Upvotes: 5