- var_dump: documentation ( source)
- crypt: documentation ( source)
- str_repeat: documentation ( source)
<?php
/**
* crypt-test-salt-nul-bytes.php
*/
$saltLen = 16;
$prefix = '$5$';
$length = 63;
$plain = 'hello';
$salt = str_repeat("\0", $saltLen);
$salt[15] = '.';
$salt[0] = '.';
$salt = "";
$result = crypt($plain, $prefix . $salt);
var_dump($result);
echo strlen($result) !== $length ? 'FAIL' : 'OK';