Created
October 8, 2025 11:21
-
-
Save alirezaarzehgar/b7fc04279b963d2b2a13fc0263ae2972 to your computer and use it in GitHub Desktop.
cli JWT editor
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
| #!/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" |
Author
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
run following command to instsall jwteditor.