- array_search: documentation ( source)
- str_replace: documentation ( source)
- base64_encode: documentation ( source)
- md5: documentation ( source)
<?php
$md5s = [];
for ($id=1; true; $id++) {
$md5 = str_replace(
['+', '/', '='],
'',
base64_encode(md5($id . 'something'))
);
if (($collision = array_search($md5, $md5s)) !== false) {
exit("collision: {$id}, {$md5s[$collision]}");
}
if ($id % 100 === 0) {
echo "{$id} iterations; no collisions so far\n";
}
}