Skip to main content

Crate threencr

Crate threencr 

Source
Expand description

Rust implementation of the 3ncr.org v1 string encryption standard.

The v1 envelope is 3ncr.org/1#<base64(iv[12] || ciphertext || tag[16])> using AES-256-GCM with a 12-byte random IV and base64 without padding. The envelope is agnostic of how the 32-byte AES key was derived; pick a constructor based on the entropy of the input secret.

use threencr::TokenCrypt;

let tc = TokenCrypt::from_sha3("some-high-entropy-api-token");
let enc = tc.encrypt_3ncr("hello");
assert_eq!(tc.decrypt_if_3ncr(&enc).unwrap(), "hello");

Structs§

TokenCrypt
A 3ncr.org v1 encrypter/decrypter bound to a 32-byte AES key.

Enums§

TokenCryptError
Errors returned by TokenCrypt.

Constants§

HEADER_V1
3ncr.org v1 envelope header.