Asymmetric Encryption

RSA

  • Generate Private Key

$ openssl genrsa -out private.pem $key_length

Generating RSA private key, $key_length bit long modulus

.++++++++++++

...++++++++++++

e is 65537 (0x10001)
  • Generate Public Key by Private Key

$ openssl rsa -in private.pem -out public.pem -outform PEM -pubout
writing RSA key
  • Encrypt file by Public Key

$ openssl rsautl -encrypt -inkey public.pem -pubin -in file -out file.rsa
  • Decrypt file by Private Key

$ openssl rsautl -decrypt -inkey private.pem -in file.rsa -out file

Remark:

  • If you have a large size file, your private key may need to extend its length

Last updated

Was this helpful?