array( 'blowfish' => '$2a$%02d$%s', ), 'saltLength' => array( 'blowfish' => 22, ), 'costLimits' => array( 'blowfish' => array(4, 31), ) ); extract($options); if ($type === null) { $hashType = self::$hashType; } else { $hashType = $type; } $cost = self::$hashCost; if ($salt === false) { if (isset($costLimits[$hashType]) && ($cost < $costLimits[$hashType][0] || $cost > $costLimits[$hashType][1])) { trigger_error(__d( 'cake_dev', 'When using %s you must specify a cost between %s and %s', array( $hashType, $costLimits[$hashType][0], $costLimits[$hashType][1] ) ), E_USER_WARNING); return ''; } $salt = self::salt($saltLength[$hashType]); $vspArgs = array( $cost, $salt, ); $salt = vsprintf($saltFormat[$hashType], $vspArgs); } elseif ($salt === true || strpos($salt, '$2a$') !== 0 || strlen($salt) < 29) { trigger_error(__d( 'cake_dev', 'Invalid salt: %s for %s Please visit http://www.php.net/crypt and read the appropriate section for building %s salts.', array($salt, $hashType, $hashType) ), E_USER_WARNING); return ''; } return crypt($password, $salt); } }