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

is time to be a bash scripting....
ლ(¯ロ¯"ლ)
Post Reply
User avatar
Kosmito
Site Admin
Posts: 17
Joined: Mon Jan 09, 2023 7:16 pm
Contact:

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

Post 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

Code: Select all

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>
Image
Image
Post Reply