php 如何在laravel 5中解码哈希值?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/32942475/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How can i decode hash value in laravel 5?
提问by aniruddh
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-
当我使用 Crypt::decrypt 我得到错误。错误-
DecryptException in BaseEncrypter.php line 45:
The payload is invalid.
Can any one suggest me how can i do that?
任何人都可以建议我该怎么做?
Thanks.
谢谢。
回答by Abdulla Nilam
Use Crypt::decrypt()
用 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.
注意:您必须使用用于加密它的相同密钥来解密该值。
Laravel 的加密例程
Config::get('app.key')
用于加密。这发生在内部。因为这个值对于每个 Laravel 应用程序都是不同的,所以加密一个值的应用程序也必须解密这个值。或者 ...
应用程序必须
Crypt::setKey()
在decrypting
将密钥与用于加密的值匹配之前调用。请参阅设置加密密钥。
To Encryption use
加密使用
Crypt::setKey($key);
This key will be used for subsequent
Crypt::encrypt()
andCrypt::decrypt()
calls.
该密钥将用于后续
Crypt::encrypt()
和Crypt::decrypt()
电话。