Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save matheussantana/d29818597df3578ae97a915ab77daa9a to your computer and use it in GitHub Desktop.
Save matheussantana/d29818597df3578ae97a915ab77daa9a to your computer and use it in GitHub Desktop.
This is a sample openssl bash script to create a matching RSA key pair and create a signed sha1 digest of the script itself using the private key. The digest is then verified against the public key.
#!/bin/bash
#create our key pairs
openssl genrsa -out private.pem 2048
openssl rsa -in private.pem -pubout -out public.pem
#sign and verify
openssl dgst -sha1 -sign private.pem -out "$0".sha1 $0
openssl dgst -sha1 -verify public.pem -signature "$0".sha1 $0
#purposely not cleaning up after the program.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment