Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/badboy/nobsign
A simple but effective sign library, written in Rust
https://github.com/badboy/nobsign
Last synced: 24 days ago
JSON representation
A simple but effective sign library, written in Rust
- Host: GitHub
- URL: https://github.com/badboy/nobsign
- Owner: badboy
- License: bsd-3-clause
- Created: 2015-10-13T12:59:53.000Z (over 9 years ago)
- Default Branch: master
- Last Pushed: 2019-01-16T15:05:42.000Z (about 6 years ago)
- Last Synced: 2024-12-24T02:01:30.604Z (28 days ago)
- Language: Rust
- Homepage: https://docs.rs/crate/nobsign
- Size: 995 KB
- Stars: 10
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# nobsign
[![crates.io](http://meritbadge.herokuapp.com/nobsign)](https://crates.io/crates/nobsign)
[![Build Status](https://travis-ci.org/badboy/nobsign.svg?branch=master)](https://travis-ci.org/badboy/nobsign)A simple but effective sign library, written in Rust.
Ported from [nobi](https://github.com/cyx/nobi),
which itself is a port of [itsdangerous](http://pythonhosted.org/itsdangerous/).## Documentation
[Online Documentation](https://docs.rs/crate/nobsign).
## Possible use cases
* Creating an activation link for users
* Creating a password reset link## Basic Example:
```rust
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
```rust
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
```