How to get the integrity value for a jquery version for script

19,150

Solution 1

Use https://www.srihash.org/ for generate link

https://code.jquery.com/jquery-3.3.1.min.js

generated as

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

Solution 2

Is this something that you are looking for?

<script
  src="https://code.jquery.com/jquery-3.3.1.js"
  integrity="sha256-2Kok7MbOyxpgUVvAk/HJ2jigOSYS2auK4Pfzbm7uH60="
  crossorigin="anonymous"></script>

I found this from here -

jQuery Core – All Versions

Solution 3

Maybe someone is also looking for a way without sending your files to a third-party website but just calculate the integrity value locally.

As the suggested site srihash.org describes, it's definately possible with following command (in bash):

openssl dgst -sha384 -binary jquery-3.3.1.min.js | openssl base64 -A

If you would rather like using other algorythms you can do so by specifying them instead of -sha384 e.g. -sha512.

Share:
19,150
user2761895
Author by

user2761895

Updated on June 26, 2022

Comments

  • user2761895
    user2761895 over 1 year

    I have this code from somewhere

    <script src="https://code.jquery.com/jquery-1.12.3.min.js" integrity="sha256-aaODHAgvwQW1bFOGXMeX+pC4PZIPsvn2h1sArYOhgXQ=" crossorigin="anonymous"></script>
    

    But if I want to use https://code.jquery.com/jquery-3.3.1.min.js in https://code.jquery.com/jquery/

    how to get the corresponding integrity value for jquery-3.3.1.min.js?

  • Matthieu H
    Matthieu H about 2 years
    Yes but where did you find the integrity value ?
  • eyal_katz
    eyal_katz about 2 years
    This is great when you want to keep the same links in your files. Just generate the link with the integrity code for each one.