Page 1 of 1

How to Generate HASH file on JS, CSS and others files

Posted: Wed Dec 06, 2023 5:49 pm
by Kosmito
on Linux console you need to use this command

Code: Select all

bash#:openssl dgst -sha384 -binary example.js | openssl base64 -A
this is going to give you something like this

Code: Select all

grSmhim7l2CkmGXtqSePI7cwM/7NymZ7eQkKk3WwaZyjfkef6IziTCUrHtz0NfwD
with this you go to the script or css line on the html and put this

integrity="sha384-grSmhim7l2CkmGXtqSePI7cwM/7NymZ7eQkKk3WwaZyjfkef6IziTCUrHtz0NfwD"

remember put before the hash sha384-HASH-HERE

This is a example how to need to be

Code: Select all

<link href="/Source/bootstrap/css/bootstrap.min.css" integrity="sha384-KK94CHFLLe+nY2dmCWGMq91rCGa5gtU4mk92HdvYe+M/SXH301p5ILy+dN9+nJOZ" rel="stylesheet" crossorigin="anonymous">
or on JS files

Code: Select all

<script src="/Source/bootstrap/js/bootstrap.bundle.min.js" integrity="sha384-ENjdO4Dr2bkBIFxQpeoTz1HIcje39Wm4jDKdf19U8gI4ddQ3GYNS7NTKfAdVQSZe" crossorigin="anonymous"></script>