diff --git a/jwt.php b/jwt.php index 6b9f784..c59d294 100644 --- a/jwt.php +++ b/jwt.php @@ -35,11 +35,13 @@ class jwt * @param string|null $alg The algorithm to use to sign the token (default * is HS256) * Allowed algorithms : HS256, HS512, HS384 - * @param string|null $ckey The cipher key to encrypt the payload (24 chars - * length) + * @param string|null $ckey The cipher key to encrypt the payload + * @param string|null $cipherMethod The method to cipher the payload + * des-ede3-cbc by default * @return string The Token */ - public function encode ($payload, $key, $alg = "HS256", $ckey = null) + public function encode ($payload, $key, $alg = "HS256", $ckey = null, + $cipherMethod = "des-ede3-cbc") // {{{ { if (! key_exists ($alg, $this->supportedAlgs)) @@ -52,7 +54,7 @@ class jwt if ($ckey) { $encrypt = new encrypt (); - $payload = $encrypt->encrypt ($payload, $ckey); + $payload = $encrypt->encrypt ($payload, $ckey, $cipherMethod); } $segments[] = $this->urlsafeB64Encode ($payload); $toBeSigned = implode ('.', $segments); @@ -67,13 +69,15 @@ class jwt * @param string $key The key used to sign the message * @param array|null $allowedAlg List of allowed algorithms. If null, all the * algorithms defined in $this->supportedAlgs are allowed - * @param string|null $ckey The cipher key to decrypt the payload (24 chars - * length) + * @param string|null $ckey The cipher key to decrypt the payload + * @param string|null $cipherMethod The method to cipher the payload + * des-ede3-cbc by default * @return array the decoded payload * @throw Exception if the key is not able to verify the token with the * provided password */ - public function decode ($jwt, $key, $allowedAlg = null, $ckey = null) + public function decode ($jwt, $key, $allowedAlg = null, $ckey = null, + $cipherMethod = "des-ede3-cbc") // {{{ { if ($allowedAlg === null)