Skip to content

Instantly share code, notes, and snippets.

@bitsapien
Last active November 13, 2020 05:34
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bitsapien/3b9e6986734abdfe827b789eb8615c67 to your computer and use it in GitHub Desktop.
Save bitsapien/3b9e6986734abdfe827b789eb8615c67 to your computer and use it in GitHub Desktop.
#!/usr/bin/env node
const jwtDecode = (jwt) => console.log(Buffer.from((process.argv.slice(2)[0]).split(".")[1], "base64").toString("utf-8"));
jwt = process.argv.slice(2)[0]
jwtDecode(jwt)
# jwt decode from clipboard
djwt() {
jwt `pbpaste` | python -m json.tool | bat -p -ljson
# Put the below nodejs script in your path to make the above work.
}
# print json from clipboard
djson() {
pbpaste | python -m json.tool | bat -p -ljson
}
# Usage
$ djwt
{
"iat": 1516239022,
"name": "John Doe",
"sub": "1234567890"
}
$ djson
{
"salt": 1099157286,
"therefore": -1336451396
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment