A simple but effective sign library, written in Rust
Rust
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
src
.gitignore
.travis.yml
Cargo.toml
LICENSE
README.md

README.md

nobsign

crates.io Build Status

A simple but effective sign library, written in Rust.

Ported from nobi, which itself is a port of itsdangerous.

Documentation

Online Documentation.

Possible use cases

  • Creating an activation link for users
  • Creating a password reset link

Basic Example:

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();

Example with timestamped signatures

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