Advertisement
Guest User

Untitled

a guest
Apr 3rd, 2020
376
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.69 KB | None | 0 0
  1. <?php
  2. function khash($data)
  3. { // Similar to https://www.php.net/manual/fr/function.crc32.php#111931
  4.     static $map = "ABCDEFGHJKLMNPRSTUXYZ";
  5.     $maplen = strlen($map);
  6.     $hash = bcadd(sprintf('%u',crc32($data)) , 0x100000000);
  7.     $str = "";
  8.     do
  9.     {
  10.         $str = $map[bcmod($hash, $maplen) ] . $str;
  11.         $hash = bcdiv($hash, $maplen);
  12.     }
  13.     while ($hash >= 1);
  14.     return $str;
  15. }
  16.  
  17. $hash = 'MySecretHashKey';
  18. $collisions = [];
  19.  
  20. $collisions['ENGOUSEF'] = 0xdead;
  21. $i = 1;
  22. while(true)
  23. {
  24.   $data = $hash.$i;
  25.   $h = khash($data);
  26.   if (isset($collisions[$h]))
  27.     die("Collisions $h");
  28.   $collisions[$h] = $i;
  29.   if ($i%1000 == 0)
  30.     echo "$i -> $h\n";
  31.   $i++;
  32. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement