← Quiz: JWT and API Security: all 10 questions
Quiz: JWT and API Security · Question 10 of 10
What does this print? (code)
What does this print?
import base64, json
part = base64.urlsafe_b64encode(json.dumps({"role": "student"}).encode()).rstrip(b"=")
padded = part + b"=" * (-len(part) % 4)
print(json.loads(base64.urlsafe_b64decode(padded))["role"])
- A.It raises an error without the secret
- B.student
- C.admin
- D.None
Answer & explanation
Correct answer: student
Anyone can decode a JWT payload without the secret; only the signature needs it.
Can you get the rest right without peeking?
Take the timed Quiz: JWT and API Security quiz free. Pass it to earn XP and count towards your certificate.
Start the quiz →