7    const BASE64_ALPHABET = 
'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/';
 
    8    const APRMD5_ALPHABET = 
'./0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz';
 
   17    public static function hash($mdp, $salt = 
null) {
 
   20        $salt = substr($salt, 0, 8);
 
   23        $binary = pack(
'H32', md5($mdp.$salt.$mdp));
 
   28        $binary = pack(
'H32', md5(
$context));
 
   30            $new = (
$i & 1) ? $mdp : $binary;
 
   31            if(
$i % 3) $new .= $salt;
 
   32            if(
$i % 7) $new .= $mdp;
 
   33            $new .= (
$i & 1) ? $binary : $mdp;
 
   34            $binary = pack(
'H32', md5($new));
 
   37        for (
$i = 0; 
$i < 5; 
$i++) {
 
   41            $hash = $binary[
$i].$binary[$k].$binary[$j].$hash;
 
   43        $hash = chr(0).chr(0).$binary[11].$hash;
 
   45            strrev(substr(base64_encode($hash), 2)),
 
   46            self::BASE64_ALPHABET,
 
   49        return '$apr1$'.$salt.
'$'.$hash;
 
   53    public static function salt() {
 
   57            $offset = hexdec(bin2hex(openssl_random_pseudo_bytes(1))) % 64;
 
   58            $salt .= $alphabet[$offset];
 
   63    public static function check($plain, $hash) {
 
   64        $parts = explode(
'$', $hash);
 
   65        return self::hash($plain, $parts[2]) === $hash;
 
An exception for terminatinating execution or to throw for unit testing.
static check($plain, $hash)
static hash($mdp, $salt=null)