This commit is contained in:
Rowan 2024-10-06 01:15:17 -05:00
parent 4f74c26e15
commit 5a449bf1da

16
README.md Normal file
View file

@ -0,0 +1,16 @@
# [Subresource Integrity](https://www.w3.org/TR/SRI/)
This library accepts an integrity attribute value which can be used to verify the integrity of a fetched resource.
## Supported Algorithms
Only the algorithms [required in the specification](https://www.w3.org/TR/SRI/#cryptographic-hash-functions) are supported. Those algorithms are SHA-256, SHA-384, and SHA-512. These hashing algorithms are provided by the [sha2](https://docs.rs/sha2/) crate.
# Usage
```rust
let value = "sha384-H8BRh8j48O9oYatfu5AZzq6A9RINhZO5H16dQZngK7T62em8MUt1FLm52t+eX6xO";
let integrity = Integrity::try_from(integrity_value).unwrap();
integrity.verify("alert(\'Hello, world.\');"); // true
```