Objective
A normal hash can be computed by anyone. An HMAC combines the message with a secret key: only someone who knows the key can generate a valid signature. It is used to authenticate requests and cookies.
Instructions
- The first line has the number
nof commands; each one issign key message(shows the HMAC-SHA256 signature in hexadecimal) orcheck key message signature. All fields are one word. - For
checkshowvalidif the signature matches orinvalidif not (compare withhmac.compare_digest).
2
sign secreto pedido42
check secreto pedido42 d424d81d28173d1d736e4d702be076d3f6aac548e6e7acd3a11aeb2430a6cbb7
d424d81d28173d1d736e4d702be076d3f6aac548e6e7acd3a11aeb2430a6cbb7
valid
Open the editor in full screen: the statement on the left and your code, the output and the tests on the right.
Start exercise