Skip to content
This repository has been archived by the owner on Nov 8, 2021. It is now read-only.
/ srihash-cli Public archive

A command-line utility for generating the SRI hash

License

Notifications You must be signed in to change notification settings

natemcmaster/srihash-cli

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

10 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

srihash-cli

A command-line utility for generating the hash used for subresource integrity (SRI) checks in modern browsers.

Example:

<script src="https://ajax.aspnetcdn.com/ajax/jquery/jquery-3.3.1.min.js"
        integrity="sha384-tsQFqpEReu7ZLhBV2VZlAu7zcOV+rXbYlF2cqB8txI/8aZajjp4Bqd+V6D5IgvKT" 
        crossorigin="anonymous">
</script>

Get started

Install:

$ dotnet tool install -g srihash-cli

Generate the hash:

$ srihash https://ajax.aspnetcdn.com/ajax/jquery/jquery-3.3.1.min.js
sha384-ifv0TYDWxBHzvAk2Z0n8R434FL1Rlv/Av18DXE43N/1rvHyOG4izKst0f2iSLdds

Generate the full HTML tag:

$ srihash --html https://ajax.aspnetcdn.com/ajax/jquery/jquery-3.3.1.min.js
<script src="https://ajax.aspnetcdn.com/ajax/jquery/jquery-3.3.1.min.js" integrity="sha384-tsQFqpEReu7ZLhBV2VZlAu7zcOV+rXbYlF2cqB8txI/8aZajjp4Bqd+V6D5IgvKT" crossorigin="anonymous"></script>