将PHP中的hash_hmac转换为rails等效项

I want to convert below PHP hash-code to equivalent ruby or rails code.

$publicHash = '3441df0babc2a2dda551d7cd39fb235bc4e09cd1e4556bf261bb49188f548348';
$privateHash = 'e249c439ed7697df2a4b045d97d4b9b7e1854c3ff8dd668c779013653913572e';
$content = json_encode( array( 'test' => 'content' ) );
$hash = hash_hmac('sha256', $content, $privateHash);

$content is request params hash.

I converted in ROR using,

public_hash =  '3441df0babc2a2dda551d7cd39fb235bc4e09cd1e4556bf261bb49188f548348'
private_hash = 'e249c439ed7697df2a4b045d97d4b9b7e1854c3ff8dd668c779013653913572e'
content = JSON::encode( paramsString )
hash = OpenSSL::HMAC.hexdigest(OpenSSL::Digest.new('sha256'), private_hash, content)

But no luck. Anything I am missing?

You can do like this

require 'openssl'
require 'json'

private_hash = 'e249c439ed7697df2a4b045d97d4b9b7e1854c3ff8dd668c779013653913572e'
content = { "test" => "content" }.to_json
digest = OpenSSL::Digest.new('sha256')

hash = OpenSSL::HMAC.hexdigest(digest, private_hash, content)

For more information, please see http://ruby-doc.org/stdlib-2.2.3/libdoc/openssl/rdoc/OpenSSL/HMAC.html