Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
100.00% covered (success)
100.00%
12 / 12
100.00% covered (success)
100.00%
2 / 2
CRAP
100.00% covered (success)
100.00%
1 / 1
Argon2IdHasher
100.00% covered (success)
100.00%
12 / 12
100.00% covered (success)
100.00%
2 / 2
2
100.00% covered (success)
100.00%
1 / 1
 make
100.00% covered (success)
100.00%
6 / 6
100.00% covered (success)
100.00%
1 / 1
1
 requiresRehash
100.00% covered (success)
100.00%
6 / 6
100.00% covered (success)
100.00%
1 / 1
1
1<?php
2/**
3 * Pop PHP Framework (https://www.popphp.org/)
4 *
5 * @link       https://github.com/popphp/popphp-framework
6 * @author     Nick Sagona, III <dev@noladev.com>
7 * @copyright  Copyright (c) 2009-2026 NOLA Interactive, LLC.
8 * @license    https://www.popphp.org/license     New BSD License
9 */
10
11/**
12 * @namespace
13 */
14namespace Pop\Crypt\Hashing;
15
16/**
17 * Pop Crypt Argon2ID hasher
18 *
19 * @category   Pop
20 * @package    Pop\Crypt
21 * @author     Nick Sagona, III <dev@noladev.com>
22 * @copyright  Copyright (c) 2009-2026 NOLA Interactive, LLC.
23 * @license    https://www.popphp.org/license     New BSD License
24 * @version    3.0.0
25 */
26class Argon2IdHasher extends AbstractArgon2Hasher
27{
28
29    /**
30     * Make hashed value (based on the hasher class)
31     *
32     * @param  string $value
33     * @return string
34     */
35    public function make(#[\SensitiveParameter] string $value): string
36    {
37        $options = [
38            'memory_cost' => $this->getMemoryCost(),
39            'time_cost'   => $this->getTimeCost(),
40            'threads'     => $this->getThreads(),
41        ];
42        return $this->createHash($value, PASSWORD_ARGON2ID, $options);
43    }
44
45    /**
46     * Determine if the hashed value requires re-hashing (based on the hasher class)
47     *
48     * @param  string $hashedValue
49     * @return bool
50     */
51    public function requiresRehash(string $hashedValue): bool
52    {
53        $options = [
54            'memory_cost' => $this->getMemoryCost(),
55            'time_cost'   => $this->getTimeCost(),
56            'threads'     => $this->getThreads(),
57        ];
58        return $this->needsRehash($hashedValue, PASSWORD_ARGON2I, $options);
59    }
60
61}