We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent becccdf commit 6cd5dffCopy full SHA for 6cd5dff
src/webhook.rs
@@ -18,8 +18,8 @@ use sha2::Sha256;
18
pub fn validate_signature(channel_secret: &str, signature: &str, body: &str) -> bool {
19
type HmacSha256 = Hmac<Sha256>;
20
21
- let mut mac =
22
- HmacSha256::new_varkey(channel_secret.as_bytes()).expect("HMAC can take key of any size");
23
- mac.input(body.as_bytes());
24
- encode(&mac.result().code().to_vec()) == signature
+ let mut mac = HmacSha256::new_from_slice(channel_secret.as_bytes())
+ .expect("HMAC can take key of any size");
+ mac.update(body.as_bytes());
+ encode(&mac.finalize().into_bytes().to_vec()) == signature
25
}
0 commit comments