Skip to content

Instantly share code, notes, and snippets.

@e0en
Created October 27, 2018 09:56
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save e0en/93a6d11e5fb9941556790371f335a8e2 to your computer and use it in GitHub Desktop.
Save e0en/93a6d11e5fb9941556790371f335a8e2 to your computer and use it in GitHub Desktop.
Calculate base64-encoded SHA-384 hash of a file. Useful when you need to fill "integrity" field of HTML resources.
# calc base64-encoded sha384 hash of a file
base64sha384 () {
openssl dgst -sha384 -binary < $1 | openssl enc -base64
}
@e0en
Copy link
Author

e0en commented Oct 27, 2018

usage:

$ base64sha384 style.css
cuyLnmRVmw3TYZKXl4VcOhIcn7C7mzTmEZQCGLXTKxge8ojxdskURelxoO+xMibz
<link rel="stylesheet" href="style.css" integrity="sha384-cuyLnmRVmw3TYZKXl4VcOhIcn7C7mzTmEZQCGLXTKxge8ojxdskURelxoO+xMibz" />

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment