Skip to content

Instantly share code, notes, and snippets.

@vishaltelangre
Last active January 26, 2018 10:29
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save vishaltelangre/9619338 to your computer and use it in GitHub Desktop.
Save vishaltelangre/9619338 to your computer and use it in GitHub Desktop.
encrypt/decrypt confidential file with CAST5 algorithm
  • Let's encrypt a file conf/config.json from current directory
  • Create a file named Makefile with following contents:
.PHONY: _pwd_prompt decrypt_conf encrypt_conf
 
CONF_FILE=conf/config.json
 
# 'private' task for echoing instructions
_pwd_prompt:
        @echo "Contact foo@example.com for the password."
 
# to create conf/config.json
decrypt_conf: _pwd_prompt
        openssl cast5-cbc -d -in ${CONF_FILE}.cast5 -out ${CONF_FILE}
        chmod 600 ${CONF_FILE}
 
# for updating conf/config.json
encrypt_conf: _pwd_prompt
        openssl cast5-cbc -e -in ${CONF_FILE} -out ${CONF_FILE}.cast5
  • Now, for encrypting the conf/config.json, run following command from current directory:
make encrypt_conf
  • And to decrypt it, run:
make decrypt_conf

Reference: http://ejohn.org/blog/keeping-passwords-in-source-control/

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment