Esempio n. 1
0
 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'];
 }
Esempio n. 2
0
 public function testGetSymmetricKeyGenerator()
 {
     $factory = new Factory();
     $this->assertTrue(is_null($factory->getSymmetricKeyGenerator()));
 }
Esempio n. 3
0
 /**
  * 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);
 }