Skip to content

Instantly share code, notes, and snippets.

@vchaindz
Last active July 10, 2023 15:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save vchaindz/a213c2030993b2ddea006f65851bc76b to your computer and use it in GitHub Desktop.
Save vchaindz/a213c2030993b2ddea006f65851bc76b to your computer and use it in GitHub Desktop.
use immudb Vault to store and share secrets
# 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