1#!/usr/bin/env bash
2
3set -e
4set -o pipefail
5
6USAGE="encrypt_with_epd.sh <path_to_encrypt_cli> <encrypted_file>"
7if [ $# -lt 2 ]
8then
9    echo $USAGE
10    exit 1
11fi
12
13CMD="$1 -e --pwd-fd 0"
14IN=$2
15OUT_DIR="./epd_encrypted_last"
16ALGOS=algos.txt
17PASSPHRASE_FILE="passphrase.txt"
18COMPRESSIONS=`awk '$1 == "compress" { print $2 }' algos.txt`
19CIPHERS=`awk '$1 == "cipher" { print $2 }' algos.txt`
20S2K_ALGOS=`awk '$1 == "s2k_algo" { print $2 }' algos.txt`
21
22mkdir -p $OUT_DIR
23for EXT in epd asc
24do
25    for COMPRESS in $COMPRESSIONS
26    do
27        for CIPHER in $CIPHERS
28        do
29            for S2K_ALGO in $S2K_ALGOS
30            do
31                ARMOR_CLAUSE=""
32                if [[ "$EXT" == "asc" ]]; then
33                    ARMOR_CLAUSE="--armor"
34                fi
35                echo "encrypting ${CIPHER} ${S2K_ALGO} ${COMPRESS} ${EXT}"
36                cat $PASSPHRASE_FILE | $CMD -o ${OUT_DIR}/${CIPHER}_${S2K_ALGO}_${COMPRESS}.${EXT} --compress-algo $COMPRESS --s2k-digest-algo $S2K_ALGO --cipher-algo $CIPHER $ARMOR_CLAUSE $IN
37            done
38        done
39    done
40done
41