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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T13:34:24+00:00 2026-06-15T13:34:24+00:00

I am computing hash in my .net and Java application.But I got a problem

  • 0

I am computing hash in my .net and Java application.But I got a problem when they gave me result because both are giving different results.While searching about this problem, I found these questions
question 1 and question 2 so applied there according tho their answers but unfortunately i didn’t get success.I also tried UTF-8 and UTF-16LE but result was again not same.

Now I am stuck and want to know why it is happening and How can I solve this
My code snippet is given below
.Net

byte[] buffer2 = new SHA1CryptoServiceProvider().ComputeHash(bytes);

Java

MessageDigest sha1 = MessageDigest.getInstance("SHA1");
        byte[] buffer2 = sha1.digest(bytes);

Any help would be greatly appreciated.

  • 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-15T13:34:24+00:00Added an answer on June 15, 2026 at 1:34 pm

    I think problem is that in C# byte is unsigned type, and in java it not.

    This 2 codes works equally:

        public static void main(String[] args) throws NoSuchAlgorithmException {
            MessageDigest sha1 = MessageDigest.getInstance("SHA1");
            byte[] bytes = new byte[] { 1, 2, 10 };
            byte[] buffer2 = sha1.digest(bytes);
            for(byte b : buffer2){
                System.out.println(b);
            }
        }
    
        static void Main(string[] args)
        {
            var bytes = new byte[] { 1, 2, 10 };
            var buffer = new SHA1CryptoServiceProvider().ComputeHash(bytes);
            foreach (var b in buffer)
            {
                Console.WriteLine((sbyte)b); //attention to cast           
            }
            Console.Read();
        }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm writing a password salt/hash procedure for my .NET application, largely following the guide
Google App Engine is a cloud computing architecture that supports java based web services
I've been trying to implement Rabin-Karp algorithm in Java. I have hard time computing
Why on the same machine computing the SHA-1 hash of the same file produces
Suppose I have a folder application/uploads EDIT application/uploads/{a}/{b}/{c}/{d}/{e}/{f}/{g}/abcdefghijklmnopqrstuvwxyz {a},{b},{c},{d},{e},{f},{g} - are hash keys, any
I've recently encountered an odd situation when computing the hash Code of tuples of
I'm having trouble computing a SHA1 hash from a string and then putting it
I'm computing the SHA-512 hash of a very large file using System.Security.Cryptography.SHA512Cng.ComputeHash , and
I'm trying to choose a hash algorithm for comparing about max 20 different text
I have two arrays of different length. I want to put them into hash,

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.