Skip to content

mjlad/encipher

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

encipher

Crates.io Docs.rs License

A fast session-data cipher for Rust.

Designed specifically for encrypting non-critical session data such as user IDs and usernames. Uses a keyed substitution cipher with rotating lookup tables seeded via ChaCha20, and HMAC-SHA256 for data integrity verification.

Not intended as a general-purpose cryptographic library. Not suitable for sensitive data such as passwords or financial information.

Installation

[dependencies]
encipher = "0.1.0"

Usage

use encipher::Encipher;

let step = 7; // controls the substitution offset (1..=255)
let cipher = Encipher::new(Some(42), None, step).unwrap();

let token   = cipher.encrypt("{\"id\":1,\"username\":\"shaya\"}");
let decoded = cipher.decrypt(&token).unwrap();

assert_eq!(decoded, "{\"id\":1,\"username\":\"shaya\"}");

Using an Environment Variable

use encipher::Encipher;

// Set APP_KEY=12345 in your environment
let cipher = Encipher::new(None, Some("APP_KEY"), 7).unwrap();

License

Licensed under the Apache License 2.0.

About

A fast session-data cipher for Rust

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages