title: Ruby on Rails passing a salt to Digest::SHA512
body: <p>what is the equivalent in Rails of this (PHP):</p>
  
  <pre><code> hash_hmac('sha512', $password . $salt, $siteSalt);
  </code></pre>
  
  <p>I got as far as this:</p>
  
  <pre><code>Digest::SHA512.hexdigest(password + salt)
  </code></pre>
  
  <p>But have no idea how to incorporate the site salt into the equation, all online examples I've seen do not pass the salt to the hexdigest method. When I've tried it I get an error for too many arguments.</p>
  
  <p>And this notation with a colon (which I saw somewhere):</p>
  
  <pre><code>salted = password + salt
  Digest::SHA512.hexdigest("#{salted}:site_salt")
  </code></pre>
  
  <p>Doesn't produce the same hash.</p>
  
  <p>Thanks</p>
  
  <p><strong>Edit</strong>
  I stumbled upon this that looks closer to what I need (sorry, I'm very new to the whole hashing thing):</p>
  
  <pre><code>OpenSSL::HMAC.hexdigest('sha512', site_salt, salted)
  </code></pre>
  
  <p>But it still produces a different hash than the one stored in the database.</p>