Skip to content

Instantly share code, notes, and snippets.

@alirezaarzehgar
Created October 8, 2025 11:21
Show Gist options
  • Select an option

  • Save alirezaarzehgar/b7fc04279b963d2b2a13fc0263ae2972 to your computer and use it in GitHub Desktop.

Select an option

Save alirezaarzehgar/b7fc04279b963d2b2a13fc0263ae2972 to your computer and use it in GitHub Desktop.
cli JWT editor
#!/usr/bin/env bash
CACHE=~/.jwt-editor.cache
if [ ! -f "${CACHE}" ]; then
echo -e "ALGORITHN=-sha512\nHEADER=\nPAYLOAD=\nSECRET=\n" > ${CACHE}
fi
sensible-editor "${CACHE}"
. ${CACHE}
b64() {
tr -d '[:space:]' | openssl base64 -e -A | tr -- '+/' '-_' | tr -d '='
}
header=$(printf "${HEADER}" | b64)
payload=$(printf "${PAYLOAD}" | b64)
signature=$(printf "${header}.${payload}" | openssl dgst "${ALGORITHN}" -binary -hmac "${SECRET}" | b64)
echo -e "$header.$payload.$signature"
@alirezaarzehgar
Copy link
Author

alirezaarzehgar commented Oct 8, 2025

run following command to instsall jwteditor.

curl -L 'https://gist.githubusercontent.com/alirezaarzehgar/b7fc04279b963d2b2a13fc0263ae2972/raw/c84747cf0ed7de54dbbf3a399a7ebe04e7fa5fda/jwted' -o /tmp/jwted && sudo install -m 775 /tmp/jwted -t /bin/

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment