Hash   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 24
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
c 0
b 0
f 0
dl 0
loc 24
rs 10
wmc 3

2 Methods

Rating   Name   Duplication   Size   Complexity  
A checkHash() 0 5 2
A hash() 0 3 1
1
<?php
2
/**
3
 * Created by PhpStorm.
4
 * User: afshin
5
 * Date: 11/13/17
6
 * Time: 3:29 PM
7
 */
8
9
namespace Core\Helpers;
10
11
class Hash{
12
    /**
13
     * Receives a string password and hashes it.
14
     *
15
     * @param string $password
16
     * @return string $hash
17
     */
18
    public static function hash($password){
19
//        return (string)password_hash($password, PASSWORD_DEFAULT);
20
        return sha1(md5($password));
21
    }
22
23
    /**
24
     * Verifies if an hash corresponds to the given password
25
     *
26
     * @param string $password
27
     * @param string $hash
28
     * @return boolean If the hash was generated from the password
29
     */
30
    public static function checkHash($string, $hash){
31
        if( password_verify( $string, $hash ) ){
32
            return true;
33
        }
34
        return false;
35
    }
36
37
}