php-internal-docs 8.4.8
Unofficial docs for php/php-src
Loading...
Searching...
No Matches
generate_unserializehash_corpus.php
Go to the documentation of this file.
1<?php
2
3$corpusDir = __DIR__ . '/corpus/unserializehash';
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}
file_put_contents(string $filename, mixed $data, int $flags=0, $context=null)
mkdir(string $directory, int $permissions=0777, bool $recursive=false, $context=null)
$ctx
hash_algos()
Definition hash.stub.php:51
hash_init(string $algo, int $flags=0, #[\SensitiveParameter] string $key="", array $options=[])
Definition hash.stub.php:30
preg_replace(string|array $pattern, string|array $replacement, string|array $subject, int $limit=-1, &$count=null)