--- /dev/null
+#!/usr/bin/env bash
+
+die() {
+ echo $@
+ exit 1
+}
+
+[ "x${SALT}" = "x" ] && die "you must set SALT to the salt."
+[ "x${PASS}" = "x" ] && die "you must set PASS to the password"
+
+RET=0
+for FILE in "$@"; do
+ if [[ "${FILE}" = *.nc ]]; then
+ BASE_FILE="$(dirname ${FILE})/$(basename ${FILE} .nc)"
+ if [ -e "${BASE_FILE}" ]; then
+ echo "Not decrypting $FILE because there is already a ${BASE_FILE}"
+ else
+ if openssl enc -d -aes-256-ecb \
+ -S "$SALT" \
+ -k "$PASS" < "${FILE}" > "${BASE_FILE}"; then
+ echo "Created ${BASE_FILE}"
+ else
+ echo "Failed to create ${BASE_FILE}"
+ RET=1
+ fi
+ fi
+ else
+ echo "Not decrypting $FILE because its name does not end in .nc"
+ fi
+done
+exit $RET
--- /dev/null
+#!/usr/bin/env bash
+
+die() {
+ echo $@
+ exit 1
+}
+
+[ "x${SALT}" = "x" ] && die "you must set SALT to the salt."
+[ "x${PASS}" = "x" ] && die "you must set PASS to the password"
+
+RET=0
+for FILE in "$@"; do
+ if [[ "${FILE}" = *.nc ]]; then
+ echo "Not encrypting ${FILE} because its name already ends in .nc"
+ else
+ NEW_FILE="${FILE}.nc"
+ if [ -e "${NEW_FILE}" ]; then
+ echo "Not encrypting ${FILE} because there is already a ${NEW_FILE}"
+ else
+ if openssl enc -aes-256-ecb \
+ -S "${SALT}" \
+ -k "${PASS}" < "${FILE}" > "${NEW_FILE}"; then
+ echo "Created ${NEW_FILE}"
+ else
+ echo "Failed to create ${NEW_FILE}"
+ RET=1
+ fi
+ fi
+ fi
+done
+exit $RET