[−][src]Crate digest_headers
Digest Headers, a simple library for verifying the content of HTTP Requests.
This library doesn't offer any verification of identity, it only ensures that the content of the request matches the signature in the Digest header of the request. If you want to verify that a request has not been tampered with, it is best to use this library in conjunction with http signatures. This way, the Headers are signed with a key, validating identity and authenticity, and the Digest header validates the body of the request.
Basic use without an HTTP library
use digest_headers::{Digest, ShaSize}; let message = b"Some message"; let digest = Digest::new(message, ShaSize::TwoFiftySix); assert!(digest.verify(message).is_ok());
Getting a Digest from a 'raw' digest string
use digest_headers::Digest; let raw_digest = "SHA-256=2EL3dJGSq4d5YyGi76VZ5ZHzq5km0aZ0k4L8g1c4Llk="; let digest = raw_digest.parse::<Digest>()?; assert!(digest.verify(br#"{"Library":"Hyper"}"#).is_ok());
Adding a Digest to a Hyper request
With the with_digest
method, a Digest can easily be added to an HTTP Request. This example
shows adding a Digest
to a Hyper Request
.
use digest_headers::{prelude::*, Digest, ShaSize}; use hyper::{Method, Request}; let uri = "http://example.com"; let body = "Some body"; let req = Request::post(uri) .with_digest(body, ShaSize::TwoFiftySix) .unwrap();
Modules
prelude | The |
Structs
Digest | Defines the |
Enums
Error | The Error type |
ShaSize | Defines variants for the size of SHA hash. |