Last active
July 10, 2023 15:19
-
-
Save vchaindz/a213c2030993b2ddea006f65851bc76b to your computer and use it in GitHub Desktop.
use immudb Vault to store and share secrets
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Encrypt and store: | |
recipient="..." | |
message=$(echo "Your Secret Message" | gpg --encrypt --armor --recipient $recipient | base64 | tr -d "\n") | |
json=$(printf '{"recipient":"%s","message":"%s"}\n' "$recipient" "$message") | |
curl -X 'PUT' 'https://vault.immudb.io/ics/api/v1/ledger/default/collection/default/document' \ | |
-H 'accept: application/json' \ | |
-H 'X-API-Key: ...' \ | |
-H 'Content-Type: application/json' \ | |
-d "$json" | |
# Retrieve and decrypt: | |
mymessage=$(curl -sX 'POST' 'https://vault.immudb.io/ics/api/v1/ledger/default/collection/default/documents/search' \ | |
-H 'accept: application/json' \ | |
-H 'X-API-Key: …' \ | |
-H 'Content-Type: application/json' \ | |
-d '{"page":1,"perPage":100}' | jq -r '.revisions[0].document.message' ) | |
## decrypt not secure! | |
echo $mymessage | base64 -d | gpg --decrypt --batch --passphrase "password" | |
## decrypt more secure | |
export GPG_TTY=$(tty) | |
echo $mymessage | base64 -d | gpg --decrypt |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment