Skip to content

Instantly share code, notes, and snippets.

@pat
Last active December 25, 2015 10:28
Show Gist options
  • Save pat/6961373 to your computer and use it in GitHub Desktop.
Save pat/6961373 to your computer and use it in GitHub Desktop.
Noting down the basics for file encryption for future reference. Particularly helpful for the next time I need to pass SSL certs around.

Basic encrypting of files to send between people who understand public/private keys.

Encrypting

Generate a random password file. The longer the better (245 characters seems to be the limit for RSA encryption though).

openssl rand 245 > key.file

Encrypt that password file with the receiver's public key. I recommend @twe4ked's catacomb for this purpose - all you need is the receiver's github username.

catacomb twe4ked < key.file > key.twe4ked

Encrypt the files you want to send using the password file as the symmetrical key:

openssl enc -aes-256-cbc -in secret.file -out secret.enc -pass file:key.file

Decrypting

Decrypt the password file using your private key. Again, catacomb makes this super easy:

catacomb < key.pat > key.file

Decrypt each file using that password file as the symmetrical key:

openssl enc -d -aes-256-cbc -in secret.enc -out secret.file -pass file:key.file
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment