gowiki/sri.sh
2016-11-20 02:14:46 +01:00

12 lines
319 B
Bash
Executable file

#!/bin/bash
HASH="sha256"
DIR="templates"
FILES="*.css *.js *.ico"
echo "SRI (subresource integrity) hashes"
cd ${DIR}
for f in $(ls ${FILES} 2>/dev/null); do
grep '^' ${f} | head -c-1 - > tmp
mv tmp ${f}
printf "%13s: " ${f}
echo "${HASH}-$(cat ${f}|openssl dgst -${HASH} -binary|openssl enc -base64 -A)"
done