diff --git a/README.md b/README.md new file mode 100644 index 0000000..239e9cc --- /dev/null +++ b/README.md @@ -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 + +``` \ No newline at end of file