Sign and verify a file using OpenSSL command line tool. It exports the digital signature in Base64 format. - JohnHau/mis GitHub Wiki
sign.sh #!/bin/bash
filename=$1 privatekey=$2
if $# -lt 2 ; then echo "Usage: sign <private_key>" exit 1 fi
openssl dgst -sha256 -sign $privatekey -out /tmp/$filename.sha256 $filename openssl base64 -in /tmp/$filename.sha256 -out signature.sha256 rm /tmp/$filename.sha256
verify.sh #!/bin/bash
filename=$1 signature=$2 publickey=$3
if $# -lt 3 ; then echo "Usage: verify <public_key>" exit 1 fi
openssl base64 -d -in $signature -out /tmp/$filename.sha256 openssl dgst -sha256 -verify $publickey -signature /tmp/$filename.sha256 $filename rm /tmp/$filename.sha256