1: <?php
2: /**
3: * PHP Password Library
4: *
5: * @package PHPassLib\Hashes
6: * @author Ryan Chouinard <rchouinard@gmail.com>
7: * @copyright Copyright (c) 2012, Ryan Chouinard
8: * @license MIT License - http://www.opensource.org/licenses/mit-license.php
9: * @version 3.0.0-dev
10: */
11:
12: namespace PHPassLib;
13:
14: /**
15: * Hashing Module Interface
16: *
17: * @package PHPassLib\Hashes
18: * @author Ryan Chouinard <rchouinard@gmail.com>
19: * @copyright Copyright (c) 2012, Ryan Chouinard
20: * @license MIT License - http://www.opensource.org/licenses/mit-license.php
21: */
22: interface Hash
23: {
24:
25: /**
26: * Generate a config string from an array.
27: *
28: * @param array $config Array of configuration options.
29: * @return string Configuration string.
30: * @throws InvalidArgumentException Throws an InvalidArgumentException if
31: * any passed-in configuration options are invalid.
32: */
33: public static function genConfig(array $config = array ());
34:
35: /**
36: * Parse a config string into an array.
37: *
38: * @param string $config Configuration string.
39: * @return array Array of configuration options or false on failure.
40: */
41: public static function parseConfig($config);
42:
43: /**
44: * Generate a password hash using a config string.
45: *
46: * @param string $password Password string.
47: * @param string $config Configuration string.
48: * @return string Returns the hash string on success. On failure, one of
49: * *0 or *1 is returned.
50: */
51: public static function genHash($password, $config);
52:
53: /**
54: * Generate a password hash using a config string or array.
55: *
56: * @param string $password Password string.
57: * @param string|array $config Optional config string or array of options.
58: * @return string Returns the hash string on success. On failure, one of
59: * *0 or *1 is returned.
60: */
61: public static function hash($password, $config = array ());
62:
63: /**
64: * Verify a password against a hash string.
65: *
66: * @param string $password Password string.
67: * @param string $hash Hash string.
68: * @return boolean Returns true if the password matches, false otherwise.
69: */
70: public static function verify($password, $hash);
71:
72: }
73: