Crypt   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 31
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 0

Importance

Changes 0
Metric Value
wmc 2
lcom 0
cbo 0
dl 0
loc 31
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A hashPassword() 0 4 1
A verifyPassword() 0 4 1
1
<?php
2
3
namespace Faulancer\Security;
4
5
/**
6
 * Class Crypt
7
 * @package Faulancer\Security
8
 * @author  Florian Knapp <[email protected]>
9
 */
10
class Crypt
11
{
12
13
    /**
14
     * Generate a hashed password string
15
     *
16
     * @param string $password
17
     *
18
     * @return bool|string
19
     *
20
     * @throws \Exception
21
     */
22
    public static 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
     *
33
     * @return bool
34
     */
35
    public static function verifyPassword(string $password, string $hash) :bool
36
    {
37
        return password_verify($password, $hash);
38
    }
39
40
}