/
class.md5.php
54 lines (51 loc) · 1.34 KB
/
class.md5.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
<?php
/**
* @package cryptography
*/
/**
* MD5 is a cryptography class for hashing and comparing messages
* using the MD5-Algorithm
*
* @since Symphony 2.3.1
* @see toolkit.Cryptography
* @deprecated This code is regarded as insecure and exists only for backwards-compatibility-purposes.
* It should not be used when writing new password-related features.
*/
Class MD5 extends Cryptography{
/**
* Uses `MD5` to create a hash based on some input
*
* @param string $input
* the string to be hashed
* @return string
* the hashed string
*/
public static function hash($input){
Symphony::Log()->pushToLog('The use of MD5::hash() is discouraged due to severe security flaws.', E_DEPRECATED, true);
return md5($input);
}
/**
* Uses `MD5` to create a hash from the contents of a file
*
* @param string $input
* the file to be hashed
* @return string
* the hashed string
*/
public static function file($input){
return md5_file($input);
}
/**
* Compares a given hash with a cleantext password.
*
* @param string $input
* the cleartext password
* @param string $hash
* the hash the password should be checked against
* @return bool
* the result of the comparison
*/
public static function compare($input, $hash){
return ($hash == self::hash($input));
}
}