

0 / 2 embers
0 / 3000 xp
click for more info
Complete a lesson to start your streak
click for more info
Difficulty: 5
click for more info
Not enough gems
Cost: 6 gems
1: What Is a Message Integrity?
incomplete
2: Message Authentication Code (MAC)
incomplete
3: Message Authentication Code (MAC)
incomplete
4: Hash-Based Message Authentication Code
incomplete
5: Toy HMAC
incomplete
6: MACs and JWTs
incomplete
7: Asymmetric JWTs
incomplete
8: Asymmetric JWT Review
incomplete
Back
ctrl+,
Next
ctrl+.
This lesson's interactive features are locked, please to keep using them
You might be thinking that it's inconvenient to only be able to validate messages with people who share a copy of the secret key. However, this is how many web applications handle authentication, including Boot.dev!
A JWT, or JSON Web Token, is just an HMAC where the message data is a JSON object. For example:
message = {"userID": "11be9160-2243-4449-934b-e8245fe2feb0"}
hmac = sha256(key1 + sha256(key2 + message))
jwt = message + "." + hmac
JWTs that use HMACs are useful for authentication because it's the same server that's issuing and validating the tokens.
I use the golang-jwt package in Go quite often, it's a great library for creating and validating JWTs.