3 * An implementation of the crypt library's SHA512 hash method
7 * @category PHPCryptLib
9 * @subpackage Derivation
10 * @author Anthony Ferrara <ircmaxell@ircmaxell.com>
11 * @copyright 2011 The Authors
12 * @license http://www.opensource.org/licenses/mit-license.html MIT License
13 * @version Build @@version@@
16 namespace CryptLib\Key\Derivation\PBKDF
;
19 * An implementation of the crypt library's SHA512 hash method
23 * @category PHPCryptLib
25 * @subpackage Derivation
26 * @author Anthony Ferrara <ircmaxell@ircmaxell.com>
29 extends \CryptLib\Key\Derivation\AbstractDerivation
30 implements \CryptLib\Key\Derivation\PBKDF
34 * Derive a key from the supplied arguments
36 * @param string $password The password to derive from
37 * @param string $salt The salt string to use
38 * @param int $iterations The number of iterations to use
39 * @param int $length The size of the string to generate
41 * @return string The derived key
43 public function derive($password, $salt, $iterations, $length) {
44 $salt = substr(str_pad($salt, 16, chr(0)), 0, 16);
45 $salt = '$5$rounds='.$iterations.'$'.$salt;
46 return crypt($password, $salt);
50 * Get the signature for this implementation
52 * This should include all information needed to build the same isntance
55 * @return string The signature for this instance
57 public function getSignature() {