Sunday, September 14, 2014

Openssl file encryption and decryption

ENCRYTPION
openssl aes-256-cbc -a -salt -in sensitive_doc.txt -out sensitive_doc.txt.enc

-a : base 64 encoding
-salt: makes it more secure
-in : unencrypted file
-out: encrypted file

DECRYPTION
openssl aes-256-cbc -d -a -in -in sensitive_doc.txt.enc -out sensitive_doc.txt.recovered



 ENC/DECRYPTION from STDIN
user@laptop:~$   echo myname is jhon
myname is jhon
user@laptop:~$ echo myname is jhon | openssl aes-256-cbc -a -salt
enter aes-256-cbc encryption password:
Verifying - enter aes-256-cbc encryption password:
U2FsdGVkX19zg6rV0yzowwvHpDwFwUJ8c8ISI1PYxuA=
user@laptop:~$ echo U2FsdGVkX19zg6rV0yzowwvHpDwFwUJ8c8ISI1PYxuA= |openssl aes-256-cbc -d -a
enter aes-256-cbc decryption password:
myname is jhon



 openssl [ list-standard-commands | list-message-digest-commands | list-
       cipher-commands | list-cipher-algorithms | list-message-digest-
       algorithms | list-public-key-algorithms