1: <?php
2: /**
3: *
4: *
5: * CakePHP(tm) : Rapid Development Framework (http://cakephp.org)
6: * Copyright (c) Cake Software Foundation, Inc. (http://cakefoundation.org)
7: *
8: * Licensed under The MIT License
9: * For full copyright and license information, please see the LICENSE.txt
10: * Redistributions of files must retain the above copyright notice.
11: *
12: * @copyright Copyright (c) Cake Software Foundation, Inc. (http://cakefoundation.org)
13: * @link http://cakephp.org CakePHP(tm) Project
14: * @since CakePHP(tm) v 2.4.0
15: * @license http://www.opensource.org/licenses/mit-license.php MIT License
16: */
17:
18: /**
19: * Abstract password hashing class
20: *
21: * @package Cake.Controller.Component.Auth
22: */
23: abstract class AbstractPasswordHasher {
24:
25: /**
26: * Configurations for this object. Settings passed from authenticator class to
27: * the constructor are merged with this property.
28: *
29: * @var array
30: */
31: protected $_config = array();
32:
33: /**
34: * Constructor
35: *
36: * @param array $config Array of config.
37: */
38: public function __construct($config = array()) {
39: $this->config($config);
40: }
41:
42: /**
43: * Get/Set the config
44: *
45: * @param array $config Sets config, if null returns existing config
46: * @return array Returns configs
47: */
48: public function config($config = null) {
49: if (is_array($config)) {
50: $this->_config = array_merge($this->_config, $config);
51: }
52: return $this->_config;
53: }
54:
55: /**
56: * Generates password hash.
57: *
58: * @param string|array $password Plain text password to hash or array of data
59: * required to generate password hash.
60: * @return string Password hash
61: */
62: abstract public function hash($password);
63:
64: /**
65: * Check hash. Generate hash from user provided password string or data array
66: * and check against existing hash.
67: *
68: * @param string|array $password Plain text password to hash or data array.
69: * @param string Existing hashed password.
70: * @return boolean True if hashes match else false.
71: */
72: abstract public function check($password, $hashedPassword);
73:
74: }
75: