Skip to content

Instantly share code, notes, and snippets.

@x3ak
Created January 15, 2018 12:27
Show Gist options
  • Save x3ak/3077acaafe26d0f4272734d17e17b961 to your computer and use it in GitHub Desktop.
Save x3ak/3077acaafe26d0f4272734d17e17b961 to your computer and use it in GitHub Desktop.
onetimesecret generation of the secret
#/bin/bash
credentials=$(cat ~/.config/onetimesecret/credentials)
if [ "$1" == "" ]; then
secret=$(pwgen 24)
else
secret=$1
fi
temp_file=$(mktemp)
passphrase=$(pwgen 24)
echo secret: ${secret}
echo passphrase: ${passphrase}
$(curl -s -d "secret=${secret}&ttl=30&passphrase=${passphrase}" -u $(cat ~/.config/onetimesecret/credentials) https://onetimesecret.com/api/v1/share -o temp_file)
key=$(cat temp_file | python -c "import json,sys;obj=json.load(sys.stdin);print obj['secret_key'];")
rm temp_file
echo https://onetimesecret.com/secret/${key}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment