Last active
July 21, 2020 19:26
-
-
Save dustinbutterworth/0513d479dd7a5963d79edd03f8cefbf8 to your computer and use it in GitHub Desktop.
JWTTomfoolery.txt
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# convert public key to hex so openssl will use it | |
cat $FILE | xxd -p | tr -d "\\n" | |
# openssl to sign as a valid HS256 | |
echo -n "$JWT" | openssl dgst -sha256 -mac HMAC -macopt hexkey:$HEX_OF_PUBLIC_KEY | |
# decode hex to binary data then reencode it in base64 | |
#!/usr/bin/env python3 | |
import base64, binascii | |
encoded = base64.urlsafe_b64encode(binascii.a2b_hex('56f5b703202ae3d0d44f586d6c2a2cb4ff04220f2ce3a6201e96097077476c72')).decode().replace('=','') | |
print(f"Encoded: {encoded}") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment