1
0
Fork
You've already forked ssri-rs
0
Rusty implementation of Subresource Integrity https://crates.io/crates/ssri
  • Rust 100%
Find a file
2023年07月17日 22:12:32 -07:00
.github ci: change test matrix to include MSRV 2023年02月09日 10:40:58 -08:00
src feat(from_hex): Implemented Integrity::from_hex(), inverse of Integrity::to_hex() ( #11 ) 2023年07月17日 22:11:04 -07:00
.gitignore misc: stop tracking Cargo.lock in repo 2020年08月19日 20:36:20 -07:00
Cargo.toml chore: Release ssri version 9.2.0 2023年07月17日 22:12:32 -07:00
CHANGELOG.md docs: update changelog 2023年07月17日 22:12:22 -07:00
cliff.toml meta: add publishing bits 2021年09月15日 19:22:53 -07:00
clippy.toml fix(clippy): set MSRV for clippy, too 2023年02月09日 10:40:00 -08:00
CODE_OF_CONDUCT.md docs: improve doc situation a bit 2019年10月20日 16:11:17 -04:00
CONTRIBUTING.md docs: improve doc situation a bit 2019年10月20日 16:11:17 -04:00
LICENSE.md feat(license): change license to Apache-2.0 2021年09月15日 19:23:47 -07:00
Makefile.toml meta: add publishing bits 2021年09月15日 19:22:53 -07:00
README.md feat(license): change license to Apache-2.0 2021年09月15日 19:23:47 -07:00

ssri

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

Example

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

usessri::Integrity;letsource="sha256-uU0nuZNNPgilLlLX2n2r+sSE7+N6U4DukIj3rOLvzek=";letparsed: Integrity=source.parse().unwrap();assert_eq!(parsed.to_string(),source)

Generating a new hash from file data:

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

Verifying data against an SRI:

usessri::{Integrity,Algorithm};letsri=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.

Install

Using cargo-edit

$ cargo add ssri

Documentation

Features

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

Contributing

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!

License

This project is licensed under the Apache-2.0 License.