Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
CRAP
100.00% covered (success)
100.00%
1 / 1
Hash
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
100.00% covered (success)
100.00%
1 / 1
 encrypt
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
1<?php
2
3/**
4 * Provides methods for password encryption using hash().
5 *
6 * This Source Code Form is subject to the terms of the Mozilla Public License,
7 * v. 2.0. If a copy of the MPL was not distributed with this file, You can
8 * obtain one at https://mozilla.org/MPL/2.0/.
9 *
10 * @package   phpMyFAQ
11 * @author    Thorsten Rinne <thorsten@phpmyfaq.de>
12 * @copyright 2012-2026 phpMyFAQ Team
13 * @license   https://www.mozilla.org/MPL/2.0/ Mozilla Public License Version 2.0
14 * @link      https://www.phpmyfaq.de
15 * @since     2012-01-04
16 */
17
18declare(strict_types=1);
19
20namespace phpMyFAQ\EncryptionTypes;
21
22use phpMyFAQ\Encryption;
23use SensitiveParameter;
24
25/**
26 * Class Hash
27 *
28 * @package phpMyFAQ\EncryptionTypes
29 */
30class Hash extends Encryption
31{
32    /**
33     * encrypts the string str and returns the result.
34     *
35     * @param string $password String
36     */
37    #[\Override]
38    public function encrypt(#[SensitiveParameter] string $password): string
39    {
40        return hash('sha256', $password . $this->salt);
41    }
42}