https://github.com/ping/srihash
bash function/script to generate an SRI hash for a remote resource
https://github.com/ping/srihash
Last synced: 2 months ago
JSON representation
bash function/script to generate an SRI hash for a remote resource
- Host: GitHub
- URL: https://github.com/ping/srihash
- Owner: ping
- License: mit
- Created: 2017-05-19T08:08:16.000Z (almost 8 years ago)
- Default Branch: master
- Last Pushed: 2017-05-19T09:21:42.000Z (almost 8 years ago)
- Last Synced: 2025-01-18T00:42:20.478Z (4 months ago)
- Language: Shell
- Size: 7.81 KB
- Stars: 2
- Watchers: 0
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# srihash
bash function/script to generate an SRI hash for a remote resource## Install
Not much of an install. Use either the bash function or script version.Requires ``openssl``.
### 1. bash function
Add the ``srihash`` function to ``~/.bash_profile`````bash
curl -sL 'https://raw.githubusercontent.com/ping/srihash/master/srihash' >> ~/.bash_profile \
&& source ~/.bash_profile
```### 2. bash script
Download ``srihash.sh`` locally.```bash
curl -s -o 'srihash.sh' 'https://raw.githubusercontent.com/ping/srihash/master/srihash.sh' \
&& chmod +x srihash.sh
```## Usage
```bash
srihash 'https://url/to/a.css' 'https://url/to/another.js'
# or
./srihash.sh 'https://url/to/a.css' 'https://url/to/another.js'# Use sha256 instead
srihash 'sha256' 'https://url/to/a.css' 'https://url/to/another.js'
# or
./srihash.sh 'sha256' 'https://url/to/a.css' 'https://url/to/another.js'# Use sha512 instead
srihash 'sha512' 'https://url/to/a.css' 'https://url/to/another.js'
# or
./srihash.sh 'sha512' 'https://url/to/a.css' 'https://url/to/another.js'
```Example:
```bash
srihash 'https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/3.3.7/css/bootstrap.min.css' \
'https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/3.3.7/js/bootstrap.min.js'
```
```
==== Generating hash for: https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/3.3.7/css/bootstrap.min.css ====
sha384-BVYiiSIFeK1dGmJRAkycuHAHRg32OmUcww7on3RYdg4Va+PmSTsz/K68vbdEjh4u==== Generating hash for: https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/3.3.7/js/bootstrap.min.js ====
sha384-Tc5IQib027qvyjSMfHjOMaLkfuWVxZxUPnCJA7l2mCWNIpG9mGCD8wGNIcPD7Txa```
The generated ````/``<link>`` markup will automatically be copied to the clipboard.