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 6cd5dff commit 4f8163aCopy full SHA for 4f8163a
examples/create_signature.rs
@@ -10,10 +10,10 @@ use sha2::Sha256;
10
pub fn create_signature(channel_secret: &str, body: &str) -> String {
11
type HmacSha256 = Hmac<Sha256>;
12
13
- let mut mac =
14
- HmacSha256::new_varkey(channel_secret.as_bytes()).expect("HMAC can take key of any size");
15
- mac.input(body.as_bytes());
16
- return encode(&mac.result().code().to_vec());
+ let mut mac = HmacSha256::new_from_slice(channel_secret.as_bytes())
+ .expect("HMAC can take key of any size");
+ mac.update(body.as_bytes());
+ return encode(&mac.finalize().into_bytes().to_vec());
17
}
18
19
fn main() {
0 commit comments