I have to convert my hash password into string.
here is my code.
<?php namespace App\Http\Controllers;
use DB;
use Auth;
use Input;
use Session;
use Route;
use Crypt;
use Redirect;
use Illuminate\Http\Request;
use Illuminate\Http\Dispatcher;
$userdata = array(
'email' => $email,
'password' => Crypt::decrypt($password)
);
when i use Crypt::decrypt i get error . error-
DecryptException in BaseEncrypter.php line 45:
The payload is invalid.
Can any one suggest me how can i do that?
Thanks.
@ershakti Passwords are hashed, not encrypted. That means they can't be reversed into their plain text form. This is for security reasons.
Hash functions are created to not be decrypted, their algorithms are public. The only way to decrypt a hash is to know the input data.
From Laravel 5 onward, you can use the bcrypt() function to hash a plaintext. So, you can save that hashed password in DB and then, compare the hashed password again to match. $save_password = bcrypt('plain_text_password'); $check_password = bcrypt('provided_password_while_login_request'); And then, compare these two.
Use Crypt::decrypt()
$value = Crypt::decrypt($encrypted);
Note : You must decrypt the value with the same key used to encrypt it.
Laravel's encryption routines use
Config::get('app.key')
for encryption. This happens internally. Since this value is different for every Laravel application then the application that encrypts a value must also decrypt the value.Or ...
The application must call
Crypt::setKey()
prior todecrypting
to match the key to the value used for encrypting. See Setting the Encryption Key.
To Encryption use
Crypt::setKey($key);
This key will be used for subsequent
Crypt::encrypt()
andCrypt::decrypt()
calls.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With