php - Laravel 4 - Hashing same password gives different values -
php - Laravel 4 - Hashing same password gives different values -
i trying authenticate user using auth::attempt() method , keeps failing, ended next code:
$arr = array(); $arr['verified'] = hash::make('1234') . ' ; ' . hash::make('1234'); homecoming json_encode($arr); and result:
{"verified":"$2y$10$v4yxbucxealflrzoe\/xad.sj8qpnhrma6k6denbbxyqavx1zsetgy ; $2y$10$c9xpowltuyfy1kl.y3tot.kwadmqyfk\/haf6uzggxtkcvh52qhs4m"} as can see, first hash gives $2y$10$v4yxbucxealflrzoe\/xad.sj8qpnhrma6k6denbbxyqavx1zsetgy , sec hash gives $2y$10$c9xpowltuyfy1kl.y3tot.kwadmqyfk\/haf6uzggxtkcvh52qhs4m
this should have nil database though when storing, have 60 character password field.
any ideas?
this fine , way supposed work. laravel uses bcrypt hashing , hence generating random salt during hashing process. salt part of hash why getting 2 different results.
the veryfing algorithm taking salt consideration automatically. method makes utilize of rainbow tables impossible.
it's not bug, it's security no effort.
given illustration veryfing against both of hashes homecoming true:
<?php $hash1 = hash::make('1234'); // hash generated $hash2 = hash::make('1234'); // hash generated differs first 1 var_dump(hash::check('1234', $hash1) && hash::check('1234', $hash2)); although $hash1 , $hash2 contain different hashes, veryfing against them given base of operations string evaluate true.
the generated hash has length of 60 characters. should made sure column hash stored has minimum size of 60 characters
php authentication hash laravel-4
Comments
Post a Comment