Skip to content

Instantly share code, notes, and snippets.

@dustinbutterworth
Last active July 21, 2020 19:26
Show Gist options
  • Save dustinbutterworth/0513d479dd7a5963d79edd03f8cefbf8 to your computer and use it in GitHub Desktop.
Save dustinbutterworth/0513d479dd7a5963d79edd03f8cefbf8 to your computer and use it in GitHub Desktop.
JWTTomfoolery.txt
# 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