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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T06:24:43+00:00 2026-05-15T06:24:43+00:00

Suppose I have any long hash, like a 16 bytes MD5 or a 20

  • 0

Suppose I have any “long” hash, like a 16 bytes MD5 or a 20 bytes SHA1.
I want to reduce this hash to fit on 4 bytes, for GetHashCode() purposes.

First, I’m perfectly aware that I’ll get more collisions. That’s totally fine in my case, but I’d still prefer to get the less possible collisions.

There are several solutions to my problem:

  • I could take the 4 first bytes of the hash.
  • I could take the 4 last bytes of the hash.
  • I could take 4 random bytes of the hash.
  • I could generate a hash of the hash, involving classic prime numbers multiplications.

Are there other solutons I didn’t think about? And more importantly, what method will give me the most unique hash code? I’m currently supposing they’re almost equivalent.

Microsoft chose that the public key token of an assembly is the last 8 bytes of the SHA1 hash of its public key, so I’ll probably go for this solution but I’d like to know why.

  • 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-15T06:24:44+00:00Added an answer on May 15, 2026 at 6:24 am

    Any hash is already a reduction.

    Cryptographic hashes are designed so that no part of the data has more influence on any part of the hash than any other. So it doesn’t matter which bits of the hash you pick.

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

Sidebar

Related Questions

Suppose we have the name written in any none-latin letters - languages, like Arabic,
I have this doubt for a long time... hope anyone can enlight me. Suppose
Suppose I have any image(say passport type images where the background will be same
Suppose I have a long javascript function such as function test() { var x;
Suppose I have a json object that looks like: { id: 1, name: john
If you don't want any context or an example of why I need this,
Suppose that my machine word is 32 bits long, and I have to sort
Suppose I have a very long file, utilities.php, which contains most if not all
Suppose we have a stage with two squares, like so: Suppose we'd like the
Suppose you have a long, complicated query to pull needed results that takes some

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.