0

I had a website and passwords are stored in plain text. Now I converted to Laravel 5 and I want to convert all those plain passwords of users to Laravel encrypted password from PhpMyAdmin. Therefore, I need an SQL statement to convert all passwords which is in password column to Laravel encrypted password.

If is not possible to do it from PhpMyAdmin then please explain another alternative.

Thanks in advance.

1 Answer 1

5

You don't encrypt passwords, you hash them. There won't be a single SQL statement to perform application level hashing, loop through all the users and update their password within Laravel:

User::all()->each(function($user) {
   $user->update(['password' => bcrypt($user->password)]);
});

Note: Verify your password column's length can store the full hash. (I'd recommend just using varchar 255)

3
  • 3
    OP also note that, since the existing passwords are plain text, they should be considered compromised. After you make this transformation, you should force all users to change their password. Commented Aug 17, 2018 at 14:49
  • The plain passwords are changed but i can't login. As i saw the file when a user update password then this is used Hash::make($new_password) and at the top of the controller use Hash; is placed. Commented Aug 18, 2018 at 8:55
  • Hash::make is the same as bcrypt(). Commented Aug 19, 2018 at 21:56

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.