2020-07-01 08:59:30 +00:00
|
|
|
#!/usr/bin/env bash
|
2021-03-09 09:15:27 +00:00
|
|
|
#
|
|
|
|
# Copyright © 2014-2021 The Android Password Store Authors. All Rights Reserved.
|
|
|
|
# SPDX-License-Identifier: GPL-3.0-only
|
|
|
|
#
|
|
|
|
|
2020-07-03 05:03:17 +00:00
|
|
|
set -ex
|
2020-07-01 08:59:30 +00:00
|
|
|
|
|
|
|
# Simple script that uses OpenSSL to encrypt a provided file with a provided key, and writes the result
|
|
|
|
# to the provided path. Yes it's very needy.
|
|
|
|
|
|
|
|
INPUT_FILE=$1
|
|
|
|
OUTPUT_FILE=$2
|
|
|
|
ENCRYPT_KEY=$3
|
|
|
|
|
|
|
|
if [[ -n "$ENCRYPT_KEY" && -n "$INPUT_FILE" && -n "$OUTPUT_FILE" ]]; then
|
|
|
|
openssl enc -aes-256-cbc -md sha256 -pbkdf2 -e -in "${INPUT_FILE}" -out "${OUTPUT_FILE}" -k "${ENCRYPT_KEY}"
|
|
|
|
else
|
|
|
|
echo "Usage: ./encrypt-secret.sh <input file> <output file> <encryption key>"
|
|
|
|
fi
|