2014年5月20日 星期二

openssl encryption/decryption application

Say, we have one certificate key and one private key in hand, test.pem and test.key respectively.

[encrypt a file using private key]
openssl rsautl -encrypt -inkey /tmp/test.key -in /tmp/file.txt -out /tmp/file.ssl

[encrypt a file using certificate]
openssl rsautl -encrypt -certin -inkey /tmp/test.pem -in /tmp/file.txt -out /tmp/file.ssl

[decrypt a encrypted file using private key]
openssl rsautl -decrypt -inkey /tmp/test.key -in /tmp/file.ssl -out /tmp/file.ori

[encrypt a file using password]
openssl enc -aes-256-cbc -salt -pass pass:edison -in test.key -out test.key.enc
or
openssl rsa -in test.key -des -passout pass:edison -out test.key.enc

[decrypt a encrypted file using password]
openssl enc -aes-256-cbc -d -pass pass:edison -in test.key.enc -out test.key.ori
or
openssl rsa -in test.key.enc -passin pass:edison -out test.key.dec

沒有留言:

張貼留言