public function __construct(array $options = array()) { $options += array('kdf' => null, 'random' => null); if (is_null($options['kdf'])) { $factory = new KeyFactory(); $options['kdf'] = $factory->getKdf('kdf3'); } $this->kdf = $options['kdf']; if (is_null($options['random'])) { $options['random'] = new RandomFactory(); } $this->random = $options['random']; }
public function testGetSymmetricKeyGenerator() { $factory = new Factory(); $this->assertTrue(is_null($factory->getSymmetricKeyGenerator())); }
/** * Load an instance of the class based upon the supplied hash * * @param string $hash The hash to load from * * @return Password the created instance * @throws InvalidArgumentException if the hash wasn't created here */ public static function loadFromHash($hash) { if (!static::detect($hash)) { throw new \InvalidArgumentException('Hash Not Created Here'); } $parts = explode('$', $hash); if (count($parts) != 7) { throw new \InvalidArgumentException('Hash Not Created Here'); } $signature = $parts[2]; $factory = new KeyFactory(); $hash = $factory->getPBKDFFromSignature($signature); $iterations = $parts[3]; $size = $parts[4]; return new static($hash, $size, $iterations); }