/** * Create a new connection to the database. * @constructor * @access public * @since 1.0.0 */ public function __construct() { $cfg = Config::load(); try { $this->pdo = new PDO('mysql:host=' . $cfg->database->server . ';dbname=' . $cfg->database->database, $cfg->database->user, $cfg->database->password); } catch (PDOException $e) { throw new \Exception('Kan niet verbinden met database'); } }
public function hashPassword($email, $password) { $cfg = Config::load(); $loop = 2000; $length = 32; $algorithm = $cfg->session_hash->algorithm; $Hlength = strlen(hash($algorithm, null, true)); $blockC = ceil($length / $Hlength); $key = ""; $salt = $email . $password; for ($block = 1; $block <= $blockC; $block++) { $hmac = hash_hmac($algorithm, $salt . pack("N", $block), $password, true); $data = $hmac; for ($i = 1; $i < $loop; $i++) { $data ^= $hmac = hash_hmac($algorithm, $hmac, $password, true); } $key .= $data; } return bin2hex(substr($key, 0, $length)); }