diff options
author | Marcin Łojewski <marcin.lojewski@mlojewski.me> | 2018-06-13 20:31:56 +0300 |
---|---|---|
committer | Marcin Łojewski <marcin.lojewski@mlojewski.me> | 2018-06-13 20:31:56 +0300 |
commit | b00f61193efc3cc8340585ca70fef84a571866d4 (patch) | |
tree | df7281ec6b6508eaf00c1928dcf4da89fe84d7e2 /lib/Crypto | |
parent | 3f4c5e2b05a825a06354a90f1afc397b56a81e62 (diff) |
Fix "Use of undefined constant" error for PHP below 7.2.
Diffstat (limited to 'lib/Crypto')
-rw-r--r-- | lib/Crypto/CryptArgon2.php | 15 |
1 files changed, 11 insertions, 4 deletions
diff --git a/lib/Crypto/CryptArgon2.php b/lib/Crypto/CryptArgon2.php index a8c2d3e..14efb64 100644 --- a/lib/Crypto/CryptArgon2.php +++ b/lib/Crypto/CryptArgon2.php @@ -54,15 +54,22 @@ class CryptArgon2 extends AbstractAlgorithm * @param int $threads Number of threads to use for computing. */ public function __construct( - IL10N $localization, - $memoryCost = PASSWORD_ARGON2_DEFAULT_MEMORY_COST, - $timeCost = PASSWORD_ARGON2_DEFAULT_TIME_COST, - $threads = PASSWORD_ARGON2_DEFAULT_THREADS + IL10N $localization, $memoryCost = -1, $timeCost = -1, $threads = -1 ) { if (version_compare(PHP_VERSION, "7.2.0") === -1) { throw new \RuntimeException( "PASSWORD_ARGON2I requires PHP 7.2.0 or above." ); + } else { + if ($memoryCost === -1) { + $memoryCost = PASSWORD_ARGON2_DEFAULT_MEMORY_COST; + } + if ($timeCost === -1) { + $timeCost = PASSWORD_ARGON2_DEFAULT_TIME_COST; + } + if ($threads === -1) { + $threads = PASSWORD_ARGON2_DEFAULT_THREADS; + } } parent::__construct($localization); |