gpt4 book ai didi

php - 在 Laravel 应用程序中散列密码并 checkin 另一个

转载 作者:行者123 更新时间:2023-12-04 10:43:24 25 4
gpt4 key购买 nike

我有一个系统,其中多个 Laravel 应用程序将信息上传到个人数据库,这些数据库的信息可以通过作为系统核心的通用 Laravel API 访问。
我在我的 Laravel 应用程序中使用 hash::make 来散列我的密码,但我想在我的 Laravel API 中检查它们但是当我尝试\hash::check 密码不匹配时。

这是我在 Laravel 应用程序中的哈希代码:

            $patient = new patient();
$patient->username = $request->input('username');
$patient->password = \Hash::make($request->input('password'));
$patient->fullname = $request->input('name');
$patient->note = $request->input('note');
$patient->save();


这是我的 API 登录代码:
        $username  = $request->username;
$password = $request->password;
$patient = Patients::where('username','=',$username)->get();
if (\Hash::check($password, $patient[0]->password))
{
return response()->json($patient[count($patient)-1]);
}else {
return 0;
}

我做错了什么还是我不能做那样的事情?

谢谢 :)

I'm using Laravel 5.8

最佳答案

我的猜测是您的 config/hashing.php可以在这些应用程序之间进行不同的配置。此配置有多个选项(例如 Bcrypt、Argon2i、Argon2id 等...),并且在存储散列密码时使用哪个选项,在检查时很重要。确保它们在不同的应用程序中保持一致。

关于php - 在 Laravel 应用程序中散列密码并 checkin 另一个,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59828556/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com