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

  • SEARCH
  • Home
  • 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 8413313
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T00:53:51+00:00 2026-06-10T00:53:51+00:00

I use Crypto-JS v2.5.3 (hmac.min.js) http://code.google.com/p/crypto-js/ library to calculate client side hash and the

  • 0

I use Crypto-JS v2.5.3 (hmac.min.js) http://code.google.com/p/crypto-js/ library to calculate client side hash and the script is:

$("#PasswordHash").val(Crypto.HMAC(Crypto.SHA256, $("#pwd").val(), $("#PasswordSalt").val(), { asByte: true }));

this return something like this:

b3626b28c57ea7097b6107933c6e1f24f586cca63c00d9252d231c715d42e272

Then in Server side I use the following code to calculate hash:

private string CalcHash(string PlainText, string Salt) {
        string result = "";
        ASCIIEncoding enc = new ASCIIEncoding();
        byte[]
        baText2BeHashed = enc.GetBytes(PlainText),
        baSalt = enc.GetBytes(Salt);
        System.Security.Cryptography.HMACSHA256 hasher = new HMACSHA256(baSalt);
        byte[] baHashedText = hasher.ComputeHash(baText2BeHashed);
        result = string.Join("", baHashedText.ToList().Select(b => b.ToString("x")).ToArray());
        return result;
    }

and this method returned:

b3626b28c57ea797b617933c6e1f24f586cca63c0d9252d231c715d42e272

As you see there is just some zero characters that the server side method ignore that. where is the problem? is there any fault with my server side method? I just need this two value be same with equal string and salt.

  • 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-06-10T00:53:52+00:00Added an answer on June 10, 2026 at 12:53 am

    As you see there is just some zero characters that the server side method ignore that. where is the problem?

    Here – your conversion to hex in C#:

    b => b.ToString("x")
    

    If b is 10, that will just give “a” rather than “0a”.

    Personally I’d suggest a simpler hex conversion:

    return BitConverter.ToString(baHashedText).Replace("-", "").ToLowerInvariant();
    

    (You could just change "x" to "x2" instead, to specify a length of 2 characters, but it’s still a somewhat roundabout way of performing a bytes-to-hex conversion.)

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

Sidebar

Related Questions

I am trying to use com.sun.crypto.provider.SunJCE (for HMAC) in an OSGi Bundle. I am
I'm looking for a crypto library to use with Objective-C code. There is a
How can I access Microsoft's Crypto API from a client side Web application? More
I am using a third party code which uses OpenSSL Crypto library. Since OSX
I've got a repository on GitHub ( http://github.com/hrickards/PHP-Crypto ) for a little project me
I need to convert this java code in force.com apex. i tried to use
I'm attempting to use the Microsoft crypto APIs to compute an MD5 hash, but
I'm just confused about what's the padding mode used when use crypto:des_ecb_encrypt/2 in erlang.
use C#,want to upload excel file on google doc. bellow syntax use to upload
I am trying to test the crypto library that comes with openssl, I downloaded

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.