17 stable releases (9 major)

9.2.0 Jul 18, 2023
9.0.0 May 20, 2023
8.1.0 Apr 1, 2023
8.0.0 Feb 19, 2023
0.2.0 May 21, 2019

#352 in Cryptography

Download history 5852/week @ 2023-12-13 6338/week @ 2023-12-20 7362/week @ 2023-12-27 8519/week @ 2024-01-03 7575/week @ 2024-01-10 7865/week @ 2024-01-17 7448/week @ 2024-01-24 7457/week @ 2024-01-31 4107/week @ 2024-02-07 7854/week @ 2024-02-14 7482/week @ 2024-02-21 10268/week @ 2024-02-28 9150/week @ 2024-03-06 8134/week @ 2024-03-13 10325/week @ 2024-03-20 7876/week @ 2024-03-27

37,165 downloads per month
Used in 64 crates (7 directly)


609 lines


ssri, short for Standard Subresource Integrity, is a Rust library for parsing, manipulating, serializing, generating, and verifying Subresource Integrity hashes.


Parse a string as Integrity to convert it to a struct:

use ssri::Integrity;

let source = "sha256-uU0nuZNNPgilLlLX2n2r+sSE7+N6U4DukIj3rOLvzek=";

let parsed: Integrity = source.parse().unwrap();
assert_eq!(parsed.to_string(), source)

Generating a new hash from file data:

use ssri::Integrity;

// By default, generates Integrity as Sha256.
// Use IntegrityOpts to pick the algorithm yourself.
let sri = Integrity::from(b"hello world");
assert_eq!(sri.to_string(), "sha256-uU0nuZNNPgilLlLX2n2r+sSE7+N6U4DukIj3rOLvzek=");

Verifying data against an SRI:

use ssri::{Integrity, Algorithm};

let sri = Integrity::from(b"hello world");
assert_eq!(sri.check(b"hello world").unwrap(), Algorithm::Sha256);

You can also use IntegrityOpts and IntegrityChecker to generate and check subresource integrity, respectively. These allow things like multiple algorithms, and incremental/streamed data input.


Using cargo-edit

$ cargo add ssri



  • Parses and stringifies Subresource Integrity strings.
  • Generates SRI strings from raw data.
  • Strict standard compliance.
  • Multiple entries for the same algorithm.


The ssri team enthusiastically welcomes contributions and project participation! There's a bunch of things you can do if you want to contribute! The Contributor Guide has all the information you need for everything from reporting bugs to contributing entire new features. Please don't hesitate to jump in if you'd like to, or even ask us questions if something isn't clear.

All participants and maintainers in this project are expected to follow Code of Conduct, and just generally be excellent to each other.

Happy hacking!


This project is licensed under the Apache-2.0 License.


~47K SLoC