Crates.io | itsdangerous |
lib.rs | itsdangerous |
version | 0.4.1 |
source | src |
created_at | 2019-06-12 05:13:51.040672 |
updated_at | 2022-03-11 23:25:17.791712 |
description | Rust port of the popular itsdangerous python library for signing strings and sending them over untrusted channels. |
homepage | https://github.com/discordapp/itsdangerous-rs |
repository | https://github.com/discordapp/itsdangerous-rs |
max_upload_size | |
id | 140535 |
size | 78,396 |
itsdangerous-rs
A rust re-implementation of the Python library itsdangerous.
Essentially, this crate provides various helpers to pass data to untrusted environments and get it back safe and sound. Data is cryptographically signed to ensure that it has not been tampered with.
Add this to your Cargo.toml
:
[dependencies]
itsdangerous = "0.3"
Next, get to signing some dangerous strings:
use itsdangerous::{default_builder, Signer};
fn main() {
// Create a signer using the default builder, and an arbitrary secret key.
let signer = default_builder("secret key").build();
// Sign an arbitrary string, and send it somewhere dangerous.
let signed = signer.sign("hello world!");
// Unsign the string and validate that it hasn't been tampered with.
let unsigned = signer.unsign(&signed).expect("Signature was not valid");
assert_eq!(unsigned, "hello world!");
}
For more in-depth examples, check out the documentation!
Licensed under the MIT license.