image.png

This is a JSON Web Token Challenge.

Let’s take a look at the JWT we have initially using https://jwt.io

image.png

image.png

Let’s do the following:

image.png

I’ll copy my reference JWT into a file called reference.txt

We’ll use php this time. Install firebase/php-jwt using Composer first

composer require firebase/php-jwt

Here’s a program that will generate a JWT for the word images.

gen.php

<?php
require 'vendor/autoload.php';
use Firebase\JWT\JWT;

$secret_key = '1c0b76fce779f78f51be339c49445c49';

// Define the single word to encode
$word = 'images';

// Payload for JWT
$payload = [
    "magic_word" => $word
];

// Generate JWT token
$jwt = JWT::encode($payload, $secret_key, 'HS256');

// Print JWT token
echo "Magic Word: $word\n  JWT Token:\n";
echo "$jwt";
?>

Run it with: