Jwt.io can't validate JWT with valid key

Can’t validate the JWT using the key.

eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJsb2NhbGhvc3QiLCJuYW1lIjoiRGlvZ28iLCJlbWFpbCI6ImRpb2dvLmZyYWdhYmVtZmljYUBnbWFpbC5jb20ifQ==.rXrDC+Fk9p8yxwvaodFa6oN+1XpsVHtWZN+hDG7XefE=

The key for the JWT above is ‘minha-esponja’, but it is not working.

Follow my PHP code:

<?php

$key = ‘minha-esponja’;

$header = [
‘alg’ => ‘HS256’,
‘typ’ => ‘JWT’
];

$header = json_encode($header);

$header = base64_encode($header);

$payload = [
‘iss’ => ‘localhost’,
‘name’ => ‘Diogo’,
‘email’ => ‘diogo.fragabemfica@gmail.com’
];

$payload = json_encode($payload);

$payload = base64_encode($payload);

$signature = hash_hmac(‘sha256’,“$header.$payload”, $key,true);

$signature = base64_encode($signature);

echo “$header.$payload.$signature”;

echo ‘

’;

$token = “$header.$payload.$signature”;

echo $token;

Hey there!

Sorry for such delay in response! We’re doing our best in providing the best developer support experience out there, but sometimes the number of incoming questions is just too big for our bandwidth. Sorry for such inconvenience!

Do you still require further assistance from us?