/** * @param string $sealed * @param string|PasswordInterface $password * @param string $cipherMethod * @param callable $keyProvider * @param callable $saltGenerator * * @return mixed */ function unseal(string $sealed, $password, string $cipherMethod = Iron::DEFAULT_ENCRYPTION_METHOD, callable $keyProvider = null, callable $saltGenerator = null) { $password = normalize_password($password); $token = Token::fromSealed($password, $sealed, true, $keyProvider ?: default_key_provider(), $saltGenerator ?: default_salt_generator()); $json = (new Iron($cipherMethod))->decryptToken($token, $password); return json_decode($json, true); }
public function contains($id) { try { Token::fromSealed($this->password, $this->decorated->fetch($id)); return true; } catch (Throwable $e) { return false; } }
/** * @return bool */ private function tryToSetTokenFromDecorated() { if (empty($this->token)) { try { $this->token = Token::fromSealed($this->password, $this->decorated->get()); } catch (Throwable $t) { } } return isset($this->token); }