加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 大数据 > 正文

php – 如何在laravel 5中解码哈希值?

发布时间:2020-12-14 19:34:52 所属栏目:大数据 来源:网络整理
导读:我必须将我的哈希密码转换为字符串. 这是我的代码. ?php namespace AppHttpControllers; use DB; use Auth; use Input; use Session; use Route; use Crypt; use Redirect; use IlluminateHttpRequest; use IlluminateHttpDispatcher; $userdata = arr
我必须将我的哈希密码转换为字符串.

这是我的代码.

<?php namespace AppHttpControllers;
     use DB;
     use Auth;
     use Input;
     use Session;
     use Route;
     use Crypt;
     use Redirect;
     use IlluminateHttpRequest;
     use IlluminateHttpDispatcher; 

      $userdata = array(
                'email'     => $email,'password'  =>  Crypt::decrypt($password)
            );

当我使用Crypt :: decrypt我得到错误.
错误-

DecryptException in BaseEncrypter.php line 45:
The payload is invalid.

任何人都可以建议我怎么做?

谢谢.

解决方法

使用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 to decrypting to match the key to the value used for encrypting. See Setting the Encryption Key.

加密使用

Crypt::setKey($key);

This key will be used for subsequent Crypt::encrypt() and Crypt::decrypt() calls.

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读