<?php
 class vB_Utility_Password_Algorithm_Blowfish extends vB_Utility_Password_Algorithm { private $cost; protected function __construct($scheme) { $params = explode(':', $scheme); if (count($params) != 2) { throw new vB_Utility_Password_Exception_SchemeNotSupported(); } $this->cost = (int) $params[1]; parent::__construct($scheme); } public function generateToken($password) { $options['cost'] = $this->cost; $hash = password_hash($password, PASSWORD_BCRYPT, $options); return $hash; } public function verifyPassword($password, $token) { list (,,$cost,) = explode('$', $token, 4); if ($cost != $this->cost) { return false; } return password_verify($password, $token); } } 