Skip to content

Instantly share code, notes, and snippets.

@tanvirstreame
Last active August 19, 2022 10:16
Show Gist options
  • Save tanvirstreame/f1295d0393c8d366c44a2842962acfe0 to your computer and use it in GitHub Desktop.
Save tanvirstreame/f1295d0393c8d366c44a2842962acfe0 to your computer and use it in GitHub Desktop.
RSA
// Generate private.pem
openssl genrsa -out private.pem 512
// Generate public.pem
openssl rsa -in private.pem -pubout > public.pem
// Encrypt
openssl rsautl -in text.txt -out secret.enc -pubin -inkey public.pem -encrypt
// Decrypt
openssl rsautl -in secret.enc -out secret.dec -inkey private.pem -decrypt
//PCKS1 padding sign file
openssl dgst -sha1 -sign private.pem -out sha1.sign text.txt
// Verify signature
openssl dgst -sha1 -verify public.pem -signature sha1.sign text.txt
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment