Skip to content

Instantly share code, notes, and snippets.

@kolosovpetro
Last active February 20, 2022 14:56
Show Gist options
  • Select an option

  • Save kolosovpetro/c3b73d7892af0ccaebc2836660385456 to your computer and use it in GitHub Desktop.

Select an option

Save kolosovpetro/c3b73d7892af0ccaebc2836660385456 to your computer and use it in GitHub Desktop.

Required dependencies

Generate private key:

  • openssl genrsa -out private.pem 8192

Derive public key:

  • openssl rsa -in private.pem -pubout -out publickey.pub

To encrypt:

  • openssl rsautl -encrypt -pubin -inkey publickey.pub -in plaintext.txt -out plaintext.enc

To decrypt and print to the console:

  • openssl rsautl -decrypt -inkey private.pem -in plaintext.enc

To decrypt and save to the file:

  • openssl rsautl -decrypt -inkey private.pem -in plaintext.enc -out plaintext.txt
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment