<?php
/* Create a new class called Bcrypt */
class Bcrypt {
private $rounds;
public function __construct($rounds = 12) {
if(CRYPT_BLOWFISH != 1) {
throw new Exception("Bcrypt is not supported on this server, please see the following to learn more: http://php.net/crypt");
}
$this->rounds = $rounds;
}
/* Gen Salt */
private function genSalt() {
$string = str_shuffle(mt_rand());// generating a random string
$salt = uniqid($string ,true);// generating a random and unique string
/* Return */
return $salt;
}
/* Gen Hash */
public function genHash($password) {
/* 2y selects bcrypt algorithm */
/* $this->rounds is the workload factor, which is kept usually from 12 to 15 */
/* Verify Password */
public function verify($password, $existingHash) {
/* Hash new password with old hash */
$hash = crypt($password, $existingHash);
Ik had hem getest op wamp dat ging prima, daarna overgezet op een testhost die blijkbaar nog een te oude versie had dus had maar weer sha1 gebruikt voor de passwords. Ga is kijken of ik het werkend kan krijgen op een oudere versie, thx.