I am just reading about JWT to encrypt some personal data of the user so that it can be passed to other APIs securely.
var payload = new Dictionary<string, object>()
{
{"email", "test@test.com"},
{"phone", "9878987899"}
};
var encoded = JWT.JsonWebToken.Encode(payload, "secret", JwtHashAlgorithm.HS512);
Console.WriteLine(encoded); //prints encoded payload
Now i can decode the token as shown below
var decoded = JWT.JsonWebToken.Decode(encoded, "", verify:false); // no security key
Console.WriteLine(decoded);
The above code decodes the token and returns json payload which is encrypted. If you observe i didn't pass secret key
but still i can decode the token.
I passed verify:false
above. Now if i set it to true
then it fails saying Signature is Invalid
. This is the expected behaviour.
My question is , What is the purpose of security key
if anyone can decode the token by setting verify:false
?