Skip to content

Commit 6cd5dff

Browse files
committed
update: webhook.rs
1 parent becccdf commit 6cd5dff

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

src/webhook.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,8 @@ use sha2::Sha256;
1818
pub fn validate_signature(channel_secret: &str, signature: &str, body: &str) -> bool {
1919
type HmacSha256 = Hmac<Sha256>;
2020

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
21+
let mut mac = HmacSha256::new_from_slice(channel_secret.as_bytes())
22+
.expect("HMAC can take key of any size");
23+
mac.update(body.as_bytes());
24+
encode(&mac.finalize().into_bytes().to_vec()) == signature
2525
}

0 commit comments

Comments
 (0)