inemanja
inemanja

Reputation: 1371

CRC32 Collision Of Hashes Created From First 10^5 Integers?

I'm trying to create array of 100.000 unique 8 character strings. for input I have array of integers from 1 to 100.000. I'm planing to use crc32. Can I assume there wont be any collisions? P.S. I'm worrying only about collisions..

Upvotes: 1

Views: 931

Answers (1)

Alix Axel
Alix Axel

Reputation: 154543

Here's your answer.

$result = array();

for ($i = 1; $i <= 100000; ++$i) $result[sprintf('_%u', crc32($i))] = true;

if (count($result) == 100000)
{
    echo 'Yes, you can use CRC32.';
}

else
{
    echo 'Ooops, you better use another algorithm.';
}

Upvotes: 2

Related Questions