Skip to content

Instantly share code, notes, and snippets.

View atomicsamurai's full-sized avatar
🔌
Wonder what this button does?

Sandeep Chaturvedi atomicsamurai

🔌
Wonder what this button does?
  • Great White North
View GitHub Profile
@atomicsamurai
atomicsamurai / readme.md
Last active April 25, 2022 15:08 — forked from thomasdarimont/readme.md
Example for decoding a JWT Payload with your Shell (bash, zsh...)

Setup

Add this to your .profile, .bashrc, .zshrc...

decode_base64_url() {
    local len=$((${#1} % 4))
    local result="$1"
    if [ $len -eq 2 ]; then result="$1"'=='
    elif [ $len -eq 3 ]; then result="$1"'=' 
    fi
    echo "$result" | tr '_-' '/+' | openssl enc -d -base64