Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6701231
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T06:54:33+00:00 2026-05-26T06:54:33+00:00

I have this method on ruby which converts a string into a encrypted SHA

  • 0

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 few javascript online tools but I couldn’t achieve the same result)

require 'digest'
require 'iconv'
word = 'testing'
puts Digest::SHA2.new(512).hexdigest(Iconv.conv('UTF-16LE','ISO-8859-15', word))

#=> 6e42b2c2a6351036b78384212774135d99d849da3066264983e495b5f74dc922e3d361b8ea9c8527169757233ed0bd4e56b2c42aab0a21bbcca67219dc53b472

Perhaps by knowing what are the exact configurations used in the method above I could find it easier in javascript?

Thanks in advance


Just in case anybody needs that method to convert the string to hex UTF-16, here it is:

function toHex(str) {
    var group = [], i;

    for (i = 0; i < str.length; i += 1) {
        group.push(str.charCodeAt(i).toString(16));
    }

    return group.join('00') + '00';
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T06:54:33+00:00Added an answer on May 26, 2026 at 6:54 am

    The reason you’re getting different results is because the Ruby code converts 'testing' into UTF-16, and the jsSHA example is using ASCII. If you expand “testing” into 16-bit Unicode, you get "740065007300740069006e006700" in hexadecimal, which gives the same answer as Ruby. Of course, you would also need to set it to SHA-512 like you mentioned.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I would like a ruby method show which does this: anyobject.show the output of
I have this method Verify_X which is called during databind for a listbox selected
I have this method for grabbing the file name from a string URI. What
I have this method to transfer files using a FTP Server: private void TransferNeededFiles(IEnumerable<string>
I have this method in cs page: public String getToolTip(Object productId, Object imgBtnId) {
In Ruby, objects have a handy method called method_missing which allows one to handle
I'm looking for a method in Ruby which is basically this: io.ready_for_read? I just
I have this vendor-supplied TLB file, which I've used to generate a Ruby proxy
In Ruby, methods which change the object have a bang on the end: string.downcase!
I need a method written in Ruby which computes Variations. I have already written

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.