#ff1

no-std fpe

Format-preserving encryption

8 releases (5 breaking)

0.5.1 Oct 27, 2021
0.5.0 Jul 31, 2021
0.4.0 Jan 27, 2021
0.3.1 Aug 16, 2020
0.0.0 Jul 3, 2018

#239 in Cryptography

Download history 3295/week @ 2021-08-10 2163/week @ 2021-08-17 3429/week @ 2021-08-24 4569/week @ 2021-08-31 2685/week @ 2021-09-07 4160/week @ 2021-09-14 4322/week @ 2021-09-21 3933/week @ 2021-09-28 4972/week @ 2021-10-05 3325/week @ 2021-10-12 3971/week @ 2021-10-19 3260/week @ 2021-10-26 3629/week @ 2021-11-02 2562/week @ 2021-11-09 3175/week @ 2021-11-16 3089/week @ 2021-11-23

13,158 downloads per month
Used in 9 crates (3 directly)

MIT/Apache

41KB
812 lines

fpe Crates.io

This crate contains pure-Rust implementations of format-preserving encryption algorithms.

The following algorithms are implemented:

This crate requires Rust version 1.49 or greater.

License

Licensed under either of

at your option.

Contribution

Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.


lib.rs:

Format-preserving encryption algorithms.

Example

extern crate aes;
extern crate fpe;

use aes::Aes256;
use fpe::ff1::{BinaryNumeralString, FF1};

let key = [0; 32];
let radix = 2;
let pt = [0xab, 0xcd, 0xef];

let ff = FF1::<Aes256>::new(&key, radix).unwrap();
let ct = ff.encrypt(&[], &BinaryNumeralString::from_bytes_le(&pt)).unwrap();
assert_eq!(ct.to_bytes_le(), [0x75, 0xfb, 0x62]);

let p2 = ff.decrypt(&[], &ct).unwrap();
assert_eq!(p2.to_bytes_le(), pt);

Dependencies

~1MB
~19K SLoC