|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2019-09-09 10:17 UTC] patrick at heppler dot net
Description:
------------
Using password_hash with PASSWORD_ARGON2I or PASSWORD_ARGON2ID and a memory_cost of less than 8192 throws:
password_hash(): Memory cost is outside of allowed memory range
Test script:
---------------
password_hash('secret',PASSWORD_ARGON2ID,['memory_cost'=>8191])
password_hash('secret',PASSWORD_ARGON2I,['memory_cost'=>8191])
Expected result:
----------------
A hashed password
Actual result:
--------------
PHP Warning: password_hash(): Memory cost is outside of allowed memory range
PatchesPull Requests
Pull requests:
HistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Sun Oct 26 18:00:01 2025 UTC |
Okay, but with PHP 7.2.22 and PHP 7.3.9 I can use password_hash('secret',PASSWORD_ARGON2I,['memory_cost'=>1024]) password_hash('secret',PASSWORD_ARGON2ID,['memory_cost'=>1024]) and it works. So I thought it's a bug.First a correction: memory_cost is KB, not bytes, so memory_cost=8191 ~ 8MB. So the minimum is memory_cost=8. To be absolutely clear here, you're saying that this *exact* code password_hash('secret',PASSWORD_ARGON2ID,['memory_cost'=>8191]); fails with that error (in PHP 7.4) while password_hash('secret',PASSWORD_ARGON2ID,['memory_cost'=>8192]); does not?Yes, exactly! password_hash('secret',PASSWORD_ARGON2ID,['memory_cost'=>8191]); Results in: password_hash(): Memory cost is outside of allowed memory range While this works password_hash('secret',PASSWORD_ARGON2ID,['memory_cost'=>8192]); PHP is php74-php-cli-7.4.0~rc1-18.el7.remi.x86_64 on CentOS 7.6