Script which will validate SSL cert with key

Hi,

I am trying to find the script which will ask for SSL Cert and Key file name/path. The output of both should be matched and compared. If the output are same than the script final output should be Certificate Matches and if it doesn't than Output don't match .
Is there any way we can create such script.

FYI I have below commands to get output of certificate and key.

openssl rsa -noout -modulus -in example.com.key| openssl md5
openssl x509 -noout -modulus -in example.com.crt| openssl md5

Regards
SachinD