Crates.io | nobsign |
lib.rs | nobsign |
version | 0.2.0 |
source | src |
created_at | 2016-08-16 10:38:10.382281 |
updated_at | 2019-01-16 15:06:00.37216 |
description | A simple but effective sign library, written in Rust |
homepage | https://github.com/badboy/nobsign |
repository | https://github.com/badboy/nobsign |
max_upload_size | |
id | 5986 |
size | 11,917 |
A simple but effective sign library, written in Rust.
Ported from nobi, which itself is a port of itsdangerous.
use nobsign::Signer;
let signer = Signer::new(b"my secret");
// Let's say the user's ID is 101
let signed = signer.sign("101");
// You can now email this url to your users!
let url = format!("http://yoursite.com/activate/?key={}", signed);
// Later check the signature and get the value back
let unsigned = signer.unsign(&signed).unwrap();
use nobsign::TimestampSigner;
let signer = TimestampSigner::new(b"my secret");
// Let's say the user's ID is 101
let signed = signer.sign("101");
// You can now email this url to your users!
let url = format!("http://yoursite.com/activate/?key={}", signed);
// In your code, you can verify the expiration:
signer.unsign(&signed, 86400).unwrap(); // 1 day expiration