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 8936067
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T10:08:04+00:00 2026-06-15T10:08:04+00:00

I am trying to encrypt 12345 using 1111 as salt using SHA-256 encoding and

  • 0

I am trying to encrypt 12345 using 1111 as salt using SHA-256 encoding and the answer I get is: 010def5ed854d162aa19309479f3ca44dc7563232ff072d1c87bd85943d0e930
which is not same as the value returned by this site.

Here’s the code snippet:

public String getHashValue(String entity, String salt){
    byte[] hashValue = null;
    try {
        MessageDigest digest =  MessageDigest.getInstance("SHA-256");
        digest.update(entity.getBytes("UTF-8"));
        digest.update(salt.getBytes("UTF-8"));
        hashValue = digest.digest();
    } catch (NoSuchAlgorithmException e) {
        Log.i(TAG, "Exception "+e.getMessage());
    } catch (UnsupportedEncodingException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }
    return BasicUtil.byteArrayToHexString(hashValue);
}

I have verified my printing method with a sample from SO and result is fine. Can someone tell me what’s wrong here?

And just to clarify – when I encrypt same value & salt in iOS code, the returned value is same as the value given by the converting site.

  • 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-15T10:08:05+00:00Added an answer on June 15, 2026 at 10:08 am

    If you fill optional part for hmac secret in that site, HmacSHA256 algorithm will be used.
    Same result can be produced with this function:

    public static String getHmac(String entity, String salt) throws Exception{
        Mac mac = Mac.getInstance("HmacSHA256");
        mac.init(new SecretKeySpec(salt.getBytes(), "HmacSHA1"));
        byte[] bs = mac.doFinal(entity.getBytes());
        return new HexDumpEncoder().encode(bs); // use your favorite hex converter
    }
    

    If you want to get the same output from that site, try to hash this value “123451111” without hmac secret.

    As obvious, calling MessageDigest.update twice is equivalent to calling it once with concatenated value.

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

Sidebar

Related Questions

Newbie here. I'm trying to encrypt the user password using SHA-256 after they've made
I'm trying to encrypt an array of 256 bytes by using RSACryptoServiceProvider but I'm
I am trying to encrypt the same data using C# and Java. If the
Talking about javax.crypto.Cipher I was trying to encrypt data using Cipher.getInstance(RSA/None/NoPadding, BC) but I
I'm trying to encrypt files using my private key (in ascii format) and any
I'm trying to encrypt and decrypt data using RSA in C#. I have the
I am trying the most basic thing - encrypt data using the public key
I'm trying to encrypt/decrypt files with PBE using AES. I'm using Bouncy Casle library(lightweight
I'm trying to encrypt a string with rijndael (keysize 256 bit, blocksize 256 bit,
I'm trying to encrypt a text file using Perl and then decrypt it using

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.