~miconoco/send-files

e674cfbbc989c9bb65761051cee8153d365cdf7a — Christoph Polcin 1 year, 2 months ago fbb1aa9
support zip as ALGO / encryption, weak ...
1 files changed, 23 insertions(+), 9 deletions(-)

M send-files
M send-files => send-files +23 -9
@@ 42,10 42,6 @@ fi

[ $# -lt 1 ] || [ ! -e "$1" ] && _usage

_fname="$(echo "$_subject" | sed 's/[^-[:alnum:]]\+/-/g')"
_fname="${_fname#-}"
_fname="$(date +%F-%H%M)-${_fname%-}.${COMP}.gpg"

_archive() { # comp files...
	case "$1" in
		*gz)


@@ 78,15 74,29 @@ _pass() {
	pass "$SUBF/$_to"
}

_file_extension() { # algo
	case "$1" in
		zip) echo zip;;
		*) echo gpg;;
	esac
}

_encrypt() { # algo
	gpg --batch --passphrase-fd 3 \
		--cipher-algo "$1" \
		--sign \
		--symmetric \
		--no-symkey-cache \
	if [ "$1" = "zip" ]; then
		_file="$(mktemp --tmpdir "archive.XXX.$COMP")"
		cat - > "$_file"
		zip -0 --encrypt --junk-paths --password "$(_pass)" - "$_file"
		rm -f -- "$_file"
	else
		gpg --batch --passphrase-fd 3 \
			--cipher-algo "$1" \
			--sign \
			--symmetric \
			--no-symkey-cache \
3<<EOF
$(_pass)
EOF
	fi
}

_email() {


@@ 105,4 115,8 @@ EOF

_pass > /dev/null 2>&1 || { echo "fail to get password for $_to" 1>&2; exit 1; }

_fname="$(echo "$_subject" | sed 's/[^-[:alnum:]]\+/-/g')"
_fname="${_fname#-}"
_fname="$(date +%F-%H%M)-${_fname%-}.${COMP}.$(_file_extension "$ALGO")"

_archive "$COMP" "$@" | _encrypt "$ALGO" | _email | $SEND