From d80cb27551fa1f765fabbd40b5dbc7b28ef0140d Mon Sep 17 00:00:00 2001 From: Michael Date: Thu, 16 Aug 2018 01:44:42 +0000 Subject: [PATCH] works again --- examples/github.rs | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/examples/github.rs b/examples/github.rs index 7b9f9a5..d579177 100644 --- a/examples/github.rs +++ b/examples/github.rs @@ -10,6 +10,7 @@ extern crate failure; #[macro_use] extern crate structopt; +use std::iter::FromIterator; use std::io::{self, Read}; use std::collections::HashMap; @@ -45,11 +46,13 @@ fn main() -> Result<(), Error> { let mut payload = String::new(); io::stdin().read_to_string(&mut payload)?; let payload: Payload = serde_json::from_str(&payload)?; + println!("secret = {}", config.secret); - let secret = GenericArray::from_slice(config.secret.as_bytes()); - let mut mac = Hmac::::new(secret); + let secret = GenericArray::from_iter(config.secret.bytes()); + let mut mac = Hmac::::new(&secret); mac.input(payload.body.as_bytes()); let signature = mac.result().code().into_iter().map(|b| format!("{:02x}", b)).collect::>().join(""); + println!("sig = {}", signature); let auth = payload.headers.get("X-Hub-Signature").ok_or(err_msg("Missing auth header"))?;