title: Converting Ruby SHA to javascript
body: <p>I have this method on ruby which converts a string into a encrypted SHA code and I would like to know if it is somehow possible to achieve that using javascript?
  The fact is that I don't know exactly what are the configurations for this SHA (I believe it is 512 but I'm not sure, I tried <a href="http://jssha.sourceforge.net/" rel="nofollow">few javascript online tools</a> but I couldn't achieve the same result)</p>
  
  <pre><code>require 'digest'
  require 'iconv'
  word = 'testing'
  puts Digest::SHA2.new(512).hexdigest(Iconv.conv('UTF-16LE','ISO-8859-15', word))
  
  #=&gt; 6e42b2c2a6351036b78384212774135d99d849da3066264983e495b5f74dc922e3d361b8ea9c8527169757233ed0bd4e56b2c42aab0a21bbcca67219dc53b472
  </code></pre>
  
  <p>Perhaps by knowing what are the exact configurations used in the method above I could find it easier in javascript?</p>
  
  <p>Thanks in advance</p>
  
  <hr>
  
  <p>Just in case anybody needs that method to convert the string to hex UTF-16, here it is: </p>
  
  <pre><code>function toHex(str) {
      var group = [], i;
  
      for (i = 0; i &lt; str.length; i += 1) {
          group.push(str.charCodeAt(i).toString(16));
      }
  
      return group.join('00') + '00';
  }
  </code></pre>