Skip to content

Commit 4f8163a

Browse files
committed
update: create_signature.rs
1 parent 6cd5dff commit 4f8163a

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

examples/create_signature.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,10 @@ use sha2::Sha256;
1010
pub fn create_signature(channel_secret: &str, body: &str) -> String {
1111
type HmacSha256 = Hmac<Sha256>;
1212

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());
13+
let mut mac = HmacSha256::new_from_slice(channel_secret.as_bytes())
14+
.expect("HMAC can take key of any size");
15+
mac.update(body.as_bytes());
16+
return encode(&mac.finalize().into_bytes().to_vec());
1717
}
1818

1919
fn main() {

0 commit comments

Comments
 (0)