Difference between revisions of "Linux openssl"
From John Freier
Line 22: | Line 22: | ||
This will calculate the public key from the private key. | This will calculate the public key from the private key. | ||
+ | |||
+ | == Encrypt a file with a public key == | ||
+ | |||
+ | cat plain.txt | openssl rsautl -encrypt -pubin -inkey ./is_rsa.pub.pem > cipher.txt | ||
+ | |||
+ | == Decrypt a file with a private key == |
Revision as of 15:15, 17 November 2014
Contents
Description
The way public/private keys work, is a public key is used to encrypt data and only a private key is capable of decrypting it.
Public Key -> Encrypt.
Private Key -> Decrypt.
Example
This is a real example of public private key.
Create a public & private key.
Create a private key.
openssl genrsa -out mykey.pem 1024
Create a public key.
openssl rsa -in key.pem -pubout -out pubkey.pem
or
openssl rsa -in mykey.pem -pubout > mykey.pub
This will calculate the public key from the private key.
Encrypt a file with a public key
cat plain.txt | openssl rsautl -encrypt -pubin -inkey ./is_rsa.pub.pem > cipher.txt