/** * 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); }