Last active
March 5, 2016 09:26
-
-
Save petehamilton/e97004e84e5f29519a91 to your computer and use it in GitHub Desktop.
Revisions
-
petehamilton revised this gist
Nov 3, 2014 . 1 changed file with 2 additions and 2 deletions.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -33,5 +33,5 @@ openssl enc -aes-256-cbc -salt -in $CSV_FILE -out $CSV_FILE_ENCRYPTED -pass file echo 'Decrypting key' openssl rsautl -decrypt -inkey $PRIVATE_KEY -in KEY_FILE_ENCRYPTED -out $KEY_FILE echo 'Decrypting file' openssl enc -d -aes-256-cbc -in $CSV_FILE_ENCRYPTED -out output.txt -pass file:$KEY_FILE -
petehamilton revised this gist
Nov 3, 2014 . 1 changed file with 4 additions and 4 deletions.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -22,16 +22,16 @@ openssl rand 256 > $KEY_FILE echo 'Generating public key' openssl rsa -in $PRIVATE_KEY -passin file:$PASSWORD_FILE -pubout -outform pem > $PUBLIC_KEY echo 'Encrypting the random key' openssl rsautl -encrypt -inkey $PUBLIC_KEY -pubin -in $KEY_FILE -out $KEY_FILE_ENCRYPTED echo 'Encrypting CSV file' openssl enc -aes-256-cbc -salt -in $CSV_FILE -out $CSV_FILE_ENCRYPTED -pass file:$KEY_FILE # Send encrypted file and key across network echo 'Decrypting key' openssl rsautl -decrypt -inkey $PRIVATE_KEY -in KEY_FILE_ENCRYPTED -out $KEY_FILE echo 'Can decrypt manually with:' echo "openssl enc -d -aes-256-cbc -in ${CSV_FILE_ENCRYPTED} -out output.txt -pass file:${KEY_FILE}" -
petehamilton created this gist
Nov 3, 2014 .There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,37 @@ #! /usr/bin/env bash set -e set -u PRIVATE_KEY='private-key.pem' PUBLIC_KEY='public-key.pem' KEY_FILE="key.bin" KEY_FILE_ENCRYPTED="key.bin.enc" CSV_FILE='fixture-secret.txt' CSV_FILE_ENCRYPTED='secret.txt.enc' PASSWORD_FILE='password.txt' echo "!!! ALL PASSWORDS ARE $(cat $PASSWORD_FILE) !!!" echo 'Generating RSA key' openssl genrsa -aes256 -out $PRIVATE_KEY -passout file:$PASSWORD_FILE 4096 echo 'Generating 256 bit random key' openssl rand 256 > $KEY_FILE echo 'Generating public key' openssl rsa -in $PRIVATE_KEY -passin file:$PASSWORD_FILE -pubout -outform pem > $PUBLIC_KEY # echo 'Encrypting the random key' # openssl rsautl -encrypt -inkey $PUBLIC_KEY -pubin -in $KEY_FILE -out $KEY_FILE_ENCRYPTED echo 'Encrypting CSV file' openssl enc -aes-256-cbc -salt -in $CSV_FILE -out $CSV_FILE_ENCRYPTED -pass file:$KEY_FILE # Send encrypted file and key across network # echo 'Decrypting key' # openssl rsautl -decrypt -inkey $PRIVATE_KEY -in KEY_FILE_ENCRYPTED -out $KEY_FILE echo 'Can decrypt manually with:' echo "openssl enc -d -aes-256-cbc -in ${CSV_FILE_ENCRYPTED} -out output.txt -pass file:${KEY_FILE}"