Completed
Pull Request — master (#16)
by Flo
07:29
created

Crypt::hashPassword()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 4
rs 10
c 0
b 0
f 0
cc 1
eloc 2
nc 1
nop 1
1
<?php
2
/**
3
 * Class Crypt | Crypt.php
4
 * @package Faulancer\Security
5
 * @author  Florian Knapp <[email protected]>
6
 */
7
namespace Faulancer\Security;
8
9
/**
10
 * Class Crypt
11
 */
12
class Crypt
13
{
14
15
    /**
16
     * Generate a hashed password string
17
     *
18
     * @param string $password
19
     * @return bool|string
20
     * @throws \Exception
21
     */
22
    public function hashPassword(string $password) :string
23
    {
24
        return password_hash($password, CRYPT_BLOWFISH);
25
    }
26
27
    /**
28
     * Verify a password
29
     *
30
     * @param string $password
31
     * @param string $hash
32
     * @return bool
33
     */
34
    public function verifyPassword(string $password, string $hash) :bool
35
    {
36
        return password_verify($password, $hash);
37
    }
38
39
}