Generate Subresource Integrity (SRI) Hashes using shasum

You can generate SRI hashes using shasum with a command

shasum -b -a 256 aarral_mart_test.pdf | awk '{ print $1 }' | xxd -r -p | base64

  • The pipe-through xxd step takes the hexadecimal output from shasum and converts it to binary.
  • The second pile-through awk step is important because shasum will pass the hashed filename in its output to xxd. That can have disastrous consequences if the filename happens to have valid hex characters in it - because xxd will also decode that and pass it to base64.

Result

tQz0nYS9m+y4nak28X33gdtrPOj5DrLRU6kz6kLw8GY=

How to use the SRI hash?


<script src="https://www.aarralmart.com/test.js" integrity="sha384-tQz0nYS9m+y4nak28X33gdtrPOj5DrLRU6kz6kLw8GY=" crossorigin="anonymous"></script>

0
2023-08-22
Linux
0
0
2023-08-22
Linux
0
0

Contact Us

If you have any inquiries or feedback, please don't hesitate to reach out to us at [email protected]. We will respond to your request as soon as possible. Thank you very much for your interest!

Country profiles