dotfiles/bin/lock

15 lines
349 B
Bash
Executable file

#!/bin/sh
[ -t 2 ] && { red=$(printf "\033[31m"); sgr0=$(printf "\033[0m"); }
error() {
echo "${red}ERROR:${sgr0} ${1}" >&2;
exit 1
}
[ -n "$1" ] || error "input file missing"
[ -r "$1" ] || error "can't read input file"
printf '#!/bin/sh
openssl enc -d -aes256 -pbkdf2 -base64 <<EOF
%s
EOF' "$(openssl enc -aes256 -pbkdf2 -base64 -in "$1")"