From 1b7ec1057ad0c3e7f17e5686d96efe3f368f1415 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?F=C3=A9lix=20Saparelli?= Date: Sun, 24 Apr 2016 19:18:26 +1200 Subject: [PATCH] Expose sign() and verify() --- src/lib.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/lib.rs b/src/lib.rs index 1391fdc..8b45170 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -131,7 +131,7 @@ pub struct TokenData { /// Take the payload of a JWT and sign it using the algorithm given. /// Returns the base64 url safe encoded of the hmac result -fn sign(data: &str, secret: &[u8], algorithm: Algorithm) -> String { +pub fn sign(data: &str, secret: &[u8], algorithm: Algorithm) -> String { fn crypt(digest: D, data: &str, secret: &[u8]) -> String { let mut hmac = Hmac::new(digest, secret); hmac.input(data.as_bytes()); @@ -146,7 +146,7 @@ fn sign(data: &str, secret: &[u8], algorithm: Algorithm) -> String { } /// Compares the signature given with a re-computed signature -fn verify(signature: &str, data: &str, secret: &[u8], algorithm: Algorithm) -> bool { +pub fn verify(signature: &str, data: &str, secret: &[u8], algorithm: Algorithm) -> bool { fixed_time_eq(signature.as_ref(), sign(data, secret, algorithm).as_ref()) }