webmasterkarthi's avatar

Generate laravel 5 hashed password

I have used laravel 5.1 hash function(default password encryption) to register and login. Now, i would like to use same db for a mobile app and the web services are going to written in a sub domain . So, how to generate the same password for authentication without using laravel(may be through core php) or what is the best solution for this?

Thanks.

0 likes
4 replies
d3xt3r's avatar
d3xt3r
Best Answer
Level 29

Look at the hash function's implementation? Do you see anything specific to laravel ?

As far as i know, it uses password_hash(), you can implement the same in your web service?

1 like
bashy's avatar

Yup, you can use normal PHP function for this.

1 like
martinbean's avatar

@webmasterkarthi Look into alternative authentication protocols instead. Otherwise each client that uses your API is going to have to implement the same hashing algorithm and seed key, and if you need to change one of them then you need to change every client’s implementation.

1 like
webmasterkarthi's avatar

Yes, laravel uses password_hash() function for password encryption. Literally the following code would generate same password. Salt is a 22 character string differs every time and stored with password. So, when logging in we can use password_verify('12345', $hash).

$options=array('cost'=>'10', 'salt' =>'VQUUdxdHwwDl6LSGm1jbeNN');
echo password_hash('12345',PASSWORD_BCRYPT, $options);

Please or to participate in this conversation.