Skip to content

Commit 3285513

Browse files
authored
Add bin/decrypt_adhoc (#33)
1 parent 01e08e2 commit 3285513

1 file changed

Lines changed: 32 additions & 0 deletions

File tree

bin/decrypt_adhoc

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
#!/usr/bin/env bash
2+
3+
# shellcheck source-path=SCRIPTDIR/../
4+
5+
## Decrypt an encrypted ad-hoc variable.
6+
7+
# Load common tools
8+
CRYPTIC_REPO="$( dirname "$( cd "$( dirname "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )" )"
9+
source "${CRYPTIC_REPO}/lib/argparse.sh"
10+
source "${CRYPTIC_REPO}/lib/common.sh"
11+
12+
# Get the repository root and private key
13+
find_repository_root
14+
find_private_key
15+
16+
# Read in encrypted value
17+
if [ "$#" -ge 1 ]; then
18+
ENCRYPTED_VALUE="${1}"
19+
else
20+
read -r -e -p "Encrypted value: " ENCRYPTED_VALUE
21+
fi
22+
23+
# Decrypt it
24+
DECRYPTED_VALUE="$(decrypt_adhoc_value "${AGENT_PRIVATE_KEY_PATH}" <<<"${ENCRYPTED_VALUE}")"
25+
26+
# Print it
27+
cat <<-EOD
28+
29+
Successfully decrypted the ad-hoc secret variable:
30+
31+
"${DECRYPTED_VALUE}"
32+
EOD

0 commit comments

Comments
 (0)