1<?php
2
3$corpusDir = __DIR__ . '/corpus/unserializehash';
4@mkdir($corpusDir);
5
6foreach (hash_algos() as $algo) {
7    $ctx = hash_init($algo);
8    $algx = preg_replace('/[^-_a-zA-Z0-9]/', '_', $algo);
9    try {
10        $serialized = serialize($ctx);
11    } catch (Exception $e) {
12        echo "Hash algorithm $algo could not be serialized.\n";
13        continue;
14    }
15    file_put_contents($corpusDir . '/' . $algx, "x|" . $serialized);
16}
17