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
21 * @category PHPCryptLib
23 * @subpackage Derivation
24 * @author Anthony Ferrara <ircmaxell@ircmaxell.com>
27 extends \CryptLib\Key\Derivation\AbstractDerivation
28 implements \CryptLib\Key\Derivation\PBKDF
32 * Derive a key from the supplied arguments
34 * @param string $password The password to derive from
35 * @param string $salt The salt string to use
36 * @param int $iterations The number of iterations to use
37 * @param int $length The size of the string to generate
39 * @return string The derived key
41 public function derive($password, $salt, $iterations, $length) {
42 $salt = substr(str_pad($salt, 16, chr(0)), 0, 16);
43 $salt = '$6$rounds='.$iterations.'$'.$salt;
44 return crypt($password, $salt);
48 * Get the signature for this implementation
50 * This should include all information needed to build the same isntance
53 * @return string The signature for this instance
55 public function getSignature() {