public function HashPassword($password)
{
$random = '';
if (CRYPT_BLOWFISH == 1 && !$this->portable_hashes) {
$random = $this->get_random_bytes(16);
$hash = crypt($password, $this->gensalt_blowfish($random));
if (strlen($hash) == 60) {
return $hash;
}
}
if (CRYPT_EXT_DES == 1 && !$this->portable_hashes) {
if (strlen($random) < 3) {
$random = $this->get_random_bytes(3);
}
$hash = crypt($password, $this->gensalt_extended($random));
if (strlen($hash) == 20) {
return $hash;
}
}
if (strlen($random) < 6) {
$random = $this->get_random_bytes(6);
}
$hash = $this->crypt_private($password, $this->gensalt_private($random));
if (strlen($hash) == 34) {
return $hash;
}
// Returning '*' on error is safe here, but would _not_ be safe
// in a crypt(3)-like function used _both_ for generating new
// hashes and for validating passwords against existing hashes.
return '*';
}
/** * Run the database seeds. * * @return void */ public function run() { $passwordHasher = new PasswordHash(8, false); if (Schema::hasTable('user')) { DB::table('user')->delete(); } DB::table('user')->insert(array('username' => 'test', 'password' => $passwordHasher->HashPassword('test'), 'rights' => 0)); DB::table('user')->insert(array('username' => 'admin', 'password' => $passwordHasher->HashPassword('admin'), 'rights' => 100)); DB::table('user')->insert(array('username' => 'test2', 'password' => $passwordHasher->HashPassword('test2'), 'rights' => 0)); }