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?
UPDATE
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: