- substr: documentation ( source)
- var_dump: documentation ( source)
- crypt: documentation ( source)
<?php
function digestPassword($password, $salt = null) {
static $cryptPrefix = '$2y$10$';
return [
substr(crypt($password, $cryptPrefix . $salt . '$'), 7),
substr(crypt($password, $cryptPrefix . $salt), 7),
];
}
var_dump(digestPassword('foobar', 'jSzEr3UNlNP8CT4tDRSjr'));