Skip to content

Instantly share code, notes, and snippets.

@apolzek
Last active August 18, 2026 19:21
Show Gist options
  • Select an option

  • Save apolzek/479ec7733734269f3c7993b1f3674db5 to your computer and use it in GitHub Desktop.

Select an option

Save apolzek/479ec7733734269f3c7993b1f3674db5 to your computer and use it in GitHub Desktop.
anongist demo (macos/zsh)
#!/usr/bin/env zsh
# anongist encrypted runner (macos). AES-256-CBC/PBKDF2.
# Usage: curl -fsSL <gist-raw-url> | zsh
set -e
PAYLOAD='U2FsdGVkX193kbrS31N0Md+EKxBv0bWUy5rbw6L6QEoM8HLqHQkey8s2VzQQRrQL+Cgfd5draRedR3hE2Iv2M6iKRHYSWXpyCsl65R67JVH1tf2pAvNICK5M51okWWkwRL1BOzR+Rvl+uz/MVhwEYCfIf0aXnnnoJUvUoSOYFk0TJ8YpTN8MxuBjFVlDxsHeU5BDlw/1Bqn2S+BE0PmgKUAePuhRTKKjvrGxE5SWO7eRE+L/kkiclvSYbsXna+/xxByIoj3Z8MVLc51p9m7IQw=='
# Read the password from the terminal even under curl | zsh.
ANON_PASS=""
if { exec 9< /dev/tty; } 2>/dev/null; then
printf 'Password: ' > /dev/tty
stty -echo < /dev/tty 2>/dev/null || true
IFS= read -r ANON_PASS <&9 || true
stty echo < /dev/tty 2>/dev/null || true
printf '\n' > /dev/tty
exec 9<&-
else
printf 'Password: '
IFS= read -r ANON_PASS || true
fi
ANON_PLAIN="$(printf '%s' "$PAYLOAD" | base64 -d 2>/dev/null \
| openssl enc -d -aes-256-cbc -pbkdf2 -salt -pass pass:"$ANON_PASS" 2>/dev/null)"
ANON_RC=$?
if [ $ANON_RC -ne 0 ] || [ -z "$ANON_PLAIN" ]; then
echo "anongist: decryption failed (wrong password or corrupted payload)" >&2
exit 1
fi
printf '%s' "$ANON_PLAIN" | zsh
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment