.. _Encrypt-parseJwt: ============================================== Encrypt::parseJwt() ============================================== \\nn\\t3::Encrypt()->parseJwt(``$token = ''``); ---------------------------------------------- Parse a JWT (Json Web Token) and check the signature. If the signature is valid (and therefore the payload has not been manipulated), the payload is returned. If the signature is invalid, ``FALSE`` is returned. .. code-block:: php \nn\t3::Encrypt()->parseJwt('adhjdf.fsdfkjds.HKdfgfksfdsf'); | ``@param string $token`` | ``@return array|false`` Source Code ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ .. code-block:: php public function parseJwt( $token = '' ) { if (!$token) return false; if (substr($token, 0, 1) == '[') return false; $parts = explode('.', $token); if (count($parts) < 3) return false; $header = json_decode(base64_decode( array_shift($parts)), true); $payload = json_decode(base64_decode( array_shift($parts)), true); $signature = base64_decode(array_shift($parts)); $checkSignature = $this->createJwtSignature($header, $payload); if ($signature !== $checkSignature) return false; $payload['token'] = $token; return $payload; }