diff options
Diffstat (limited to 'dotfiles/common')
| -rwxr-xr-x | dotfiles/common/.local/bin/decryptfile | 28 | ||||
| -rwxr-xr-x | dotfiles/common/.local/bin/encryptfile | 17 |
2 files changed, 45 insertions, 0 deletions
diff --git a/dotfiles/common/.local/bin/decryptfile b/dotfiles/common/.local/bin/decryptfile new file mode 100755 index 0000000..4176450 --- /dev/null +++ b/dotfiles/common/.local/bin/decryptfile @@ -0,0 +1,28 @@ +#!/bin/bash +# Decrypt a GPG file to clipboard (symmetric) +# Usage: decryptfile <file.gpg> + +if [ -z "$1" ]; then + echo "Usage: decryptfile <file.gpg>" + exit 1 +fi + +if [ ! -f "$1" ]; then + echo "File not found: $1" + exit 1 +fi + +# Decrypt and copy to clipboard +if command -v wl-copy &> /dev/null; then + # Wayland + gpg --decrypt "$1" 2>/dev/null | wl-copy + echo "Decrypted content copied to clipboard (Wayland)" +elif command -v xclip &> /dev/null; then + # X11 + gpg --decrypt "$1" 2>/dev/null | xclip -selection clipboard + echo "Decrypted content copied to clipboard (X11)" +else + echo "No clipboard tool found (need wl-copy or xclip)" + echo "Decrypting to stdout instead:" + gpg --decrypt "$1" +fi diff --git a/dotfiles/common/.local/bin/encryptfile b/dotfiles/common/.local/bin/encryptfile new file mode 100755 index 0000000..bfe5aee --- /dev/null +++ b/dotfiles/common/.local/bin/encryptfile @@ -0,0 +1,17 @@ +#!/bin/bash +# Encrypt a file with symmetric GPG (password-based) +# Usage: encryptfile <file> + +if [ -z "$1" ]; then + echo "Usage: encryptfile <file>" + exit 1 +fi + +if [ ! -f "$1" ]; then + echo "File not found: $1" + exit 1 +fi + +gpg --symmetric --cipher-algo AES256 --armor -o "${1}.gpg" "$1" && \ + echo "Encrypted to ${1}.gpg" && \ + rm -i "$1" |
