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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T03:13:39+00:00 2026-05-25T03:13:39+00:00

What is the best hash method for an array of byte ? The arrays

  • 0

What is the best hash method for an array of byte?

The arrays are serialized class objects containing jpeg image passed between applications over TCP/IP.

The array size is about 200k.

  • 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-25T03:13:40+00:00Added an answer on May 25, 2026 at 3:13 am

    Any of the built-in hashing functions should do; depending on how much you care about collisions these are your options (from most collisions to least):

    • MD5
    • SHA1
    • SHA256
    • SHA384
    • SHA512

    They are as simple to use as:

    var hash = SHA1.Create().ComputeHash(data);
    

    Bonus Marks: If you don’t care about security (which I don’t think you do given that you are getting the hashes for images) you might want to look into Murmur hash, which is designed for content hashing and not secure hashing (and is thus much faster). It isn’t, however, in the framework so you will have to find an implementation (and you should probably go for Murmur3).

    Edit: If you are looking for a HASHCODE for a byte[] array it’s entirely up to you, it usually consists of bit shifting (by primes) and XORing. E.g.

    public class ByteArrayEqualityComparer : IEqualityComparer<byte[]>
    {
        public static readonly ByteArrayEqualityComparer Default = new ByteArrayEqualityComparer();
        private ByteArrayEqualityComparer() { }
    
        public bool Equals(byte[] x, byte[] y)
        {
            if (x == null && y == null)
                return true;
            if (x == null || y == null)
                return false;
            if (x.Length != y.Length)
                return false;
            for (var i = 0; i < x.Length; i++)
                if (x[i] != y[i])
                    return false;
            return true;
        }
    
        public int GetHashCode(byte[] obj)
        {
            if (obj == null || obj.Length == 0)
                return 0;
            var hashCode = 0;
            for (var i = 0; i < obj.Length; i++)
                // Rotate by 3 bits and XOR the new value.
                hashCode = (hashCode << 3) | (hashCode >> (29)) ^ obj[i];
            return hashCode;
        }
    }
    // ...
    var hc = ByteArrayEqualityComparer.Default.GetHashCode(data);
    

    EDIT: If you want to validate that the value hasn’t changed you should use CRC32.

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

Sidebar

Related Questions

Wondering what the best method is for communicating between a 10.5/10.6+ System Preference Pane
What is the best 32bit hash function for relatively short strings? Strings are tag
Three SHA512Managed related questions: Is SHA512Managed considered the best one-way hash available in .NET
What's the best way to implement a Hash that can be modified across multiple
I am mulling over a best practice for passing hash references for return data
http://msdn.microsoft.com/en-us/library/system.object.gethashcode(VS.80).aspx says: For the best performance, a hash function must generate a random distribution
Best method to add/remove webcontrols or user controls in asp.net for dynamic forms without
Best to describe this in code... I have this public class A<T> { public
What's the best way to determine which UITextField triggers the method -(BOOL)textFieldShouldBeginEditing:(UITextField *)textField (or
What is the best method to reset a user password when password is hashed:

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.