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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T05:20:51+00:00 2026-06-16T05:20:51+00:00

I am developing a system which needs to store a hash for a structure

  • 0

I am developing a system which needs to store a hash for a structure 20 bytes maybe less in length. However, in order to optimize the process of looking up the hash in a series of hashes, we want to reduce the size of the hash as much as possible.

So my question is this, is there a relationship between the amount of data we feed into a crc16 hash and the probability of its collision with another entry of the same length? If so, which is the most optimal length for this?

18 of the bytes fall within the ascii table (a-z, 0-9), and the remaining range between 0 and 10

  • 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-16T05:20:52+00:00Added an answer on June 16, 2026 at 5:20 am

    The following simple script runs an infinite loop that fetches 2 random 20-byte sequences, calculates CRC16 and checks if there is a collision. Continuous evaluation of this loop de facto estimates collision percentage:

    #!/usr/bin/env perl
    
    use Digest::CRC qw(crc16);
    
    open(my $f, '<', '/dev/urandom');
    my $n = 0;
    my $coll = 0;
    
    while (1) {
        read $f, $randstr1, 20;
        read $f, $randstr2, 20;
        my $crc1 = crc16($randstr1);
        my $crc2 = crc16($randstr2);
    
        $n++;
        $coll++ if $crc1 == $crc2;
    
        printf "percent of collisions = %.6f%%\n", $coll * 100.0 / $n if ($n % 100000 == 0);
    }
    

    From what I get on my computer, collision percentage seems to be around 0.0016% (or 1e-5, or “1 in 100_000”), which is way worse than predicted estimates based on ideal hashing distribution of a 16-bit hash (such as 2^16 / 2^160).

    UPDATE: I see you’ve clarified that 20 bytes are not just fully random bytes, but fall into range of [a-z0-9]. Here’s the updated version that estimates collisions in that alphabet:

    #!/usr/bin/env perl
    
    use Digest::CRC qw(crc16);
    
    my $n = 0;
    my $coll = 0;
    my @chars = ('a'..'z', '0'..'9');
    
    sub randstr() {
        my $res;
        foreach (1..20) { $res .= $chars[rand @chars]; }
        return $res;
    }
    
    while (1) {
        my $crc1 = crc16(randstr());
        my $crc2 = crc16(randstr());
    
        $n++;
        $coll++ if $crc1 == $crc2;
    
        printf "percent of collisions = %.4f%%\n", $coll * 100.0 / $n if ($n % 100000 == 0);
    }
    

    It yields approximately the same result, about 0.0016%.

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

Sidebar

Related Questions

I'm developing a system which needs to store videos in the form: /path/to/video/<md5 of
We are developing an application which needs to process huge file stored in DB
I am developing a system which needs to allow users to be placed into
I'm developing a system in ASP.NET which needs user authentication. The authentication system should
I am developing a program which needs to use os.system because of the old
I am developing a firefox extension, i need to detect which operating system firefox
I am developing a system which include a server app & a client app,
I'm developing an API system which requires this type of authentication. The user will
I am developing a simple informative system which will use a lot of images.
I'm developing an app that starts a System.Threading.Timer which does some fairly rapid reading/writing

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.