gpt4 book ai didi

php - 如何使用-with-password-argon2编译PHP?

转载 作者:行者123 更新时间:2023-12-02 06:27:52 33 4
gpt4 key购买 nike

我尝试将 PHP 的 password_hash() 函数与 PASSWORD_ARGON2I 算法一起使用,但是,我收到以下错误消息:

Warning: Use of undefined constant PASSWORD_ARGON2I - assumed 'PASSWORD_ARGON2I' (this will throw an Error in a futureversion of PHP) in some-file.php on line 181

Warning: password_hash() expects parameter 2 to be integer, string given in some-file.php on line 192

Fatal error: Uncaught PDOException: SQLSTATE[23000]: Integrity constraint violation: 1048 Column 'password' cannot be nullin some-file.php:232Stack trace:#0 some-file.php(232): PDOStatement->execute()#1 {main}thrown in some-file.php on line 232

我关注了the official documentation of the function逐字逐句,但我仍然遇到这个错误。

然后我做了一些研究,发现 "PHP should be compiled using –with-password-argon2" (where they refer to this file)。

我不知道该怎么做,也找不到任何可以指导我完成这些步骤或提供更多信息的页面。

散列函数与 PASSWORD_DEFAULT 完美配合,但这不是我目前需要的。

最佳答案

我不知道,但 OSX 预装了 PHP。我有一个非常早的版本,所以我需要升级它以使 Argon2 算法工作。当我在命令行中通过 php --version 检查我的版本时,我得到以下结果:

PHP 5.6.30 (cli) (built: Oct 29 2017 20:30:32)
Copyright (c) 1997-2016 The PHP Group
Zend Engine v2.6.0, Copyright (c) 1998-2016 Zend Technologies

所以我遵循了本指南,但我还必须安装 Argon2 库(未提及)并使用 ./configure —with-password-argon2。所以这是基于 this guide 解决我的问题的步骤:

  1. 下载最新的 PHP 源代码。 from here (我使用了 this .GZ file ,但研究一下是否有更新的版本)
  2. 打开命令行
  3. 提取GZ文件并在命令行中导航到提取的源代码文件夹
  4. 您将需要 Homebrew,如果没有,请安装它
  5. 安装 this guide 中列出的依赖项(在命令行运行brew install libjpegbrew install pcrebrew install libxml2等)
  6. 同时安装Argon2库(这个在之前的指南中没有提到,可以使用this guide)
  7. 现在在命令行中运行它(仍然是同一个源代码文件夹):./configure —with-password-argon2
  8. 在命令行中运行make test(过程比较耗时,一边喝啤酒一边喝)
  9. 之后运行 sudo make install
  10. 我还重新启动了我的电脑,不确定是否有必要,但它起作用了

关于php - 如何使用-with-password-argon2编译PHP?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51383867/

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