Skip to content

Instantly share code, notes, and snippets.

@s4parke
Last active August 14, 2019 20:01
Show Gist options
  • Save s4parke/b632921e1f13fb0297298dc325d179ab to your computer and use it in GitHub Desktop.
Save s4parke/b632921e1f13fb0297298dc325d179ab to your computer and use it in GitHub Desktop.
Server-side commands to create digital signature for image
# Make a hash of the image data
openssl dgst -sha256 wreckage.jpg > digest.txt
# Make a hash of DC metadata from XMP sidecar file
xml sel -N dc="http://purl.org/dc/elements/1.1/" -t -m "//dc:title" -c . -m "//dc:creator" -c . -m "//dc:description" -c . -n gator-meta.jpg.xml | openssl dgst -sha256 >> digest.txt
# Sign and base64 encode the digest
openssl rsautl -sign -inkey private_key.pem -keyform PEM -in digest.txt | base64 > signature
# Put the signature into the XMP sidecar file
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment