The JWT.IO website has a debugger for creating and validating JSON Web Token.
When I copy and paste my secret string into the VERIFY SIGNATURE block, I can see that it generates a signature.
I scroll down the page a little bit and found the .NET solution implemented by Microsoft. After downloading, I add my unit test to generate the signature manually.
However, the signature generated by the JWT.IO website is slightly different from the one generated by my unit test.
Secrect string: "THIS IS A SECRET STRING WHICH CAN BE SHARED BETWEEN THE SERVICES"
Unit test signature: "B0d57pcHoDiTDE/98dyrMx9HoFKGLOcM094eYBgJqHo="
JWT.IO signature: B0d57pcHoDiTDE_98dyrMx9HoFKGLOcM094eYBgJqHo
I notice that the JWT.IO signature string is URL encoding safe, but the unit test signature is not.
How do I generate the same signature as the JWT.IO website does?
The accepted answer below pointed me to the class Base64UrlEncoder
. I have modified my unit test to generate the exact same signature as JWT.IO web site does:
@Believe2014 It seems that the jwt.io
website does not have some options for specifying the base64 encoding with which way of URLEncoding to generate the same signature as your unit test.
However, according to the section 4 & 5 of RFC 4648
, the differences between both signatures are using different characters for byte 62
& 63
and whether omits padding characters =
.
So for converting the signature generated by jwt.io
into yours, just using /
instead of _
, using +
instead of -
, and adding the padding characters =
at the end of signature.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With