- crypt: documentation ( source)
- strtr: documentation ( source)
- base64_encode: documentation ( source)
- sprintf: documentation ( source)
<?php
$cost = 10; $salt = strtr(base64_encode(mcrypt_create_iv(16, MCRYPT_DEV_URANDOM)), '+', '.'); $salt = sprintf("$2a$%02d$", $cost) . $salt; $hash = crypt("thuum", $salt);
echo $hash;