9 releases (breaking)

0.6.1 Apr 13, 2023
0.5.1 Oct 27, 2021
0.5.0 Jul 31, 2021
0.4.0 Jan 27, 2021
0.1.0 Jul 31, 2018

#1017 in Cryptography

Download history 5962/week @ 2024-06-19 5298/week @ 2024-06-26 4279/week @ 2024-07-03 5300/week @ 2024-07-10 6060/week @ 2024-07-17 7054/week @ 2024-07-24 5981/week @ 2024-07-31 7017/week @ 2024-08-07 5732/week @ 2024-08-14 7347/week @ 2024-08-21 5901/week @ 2024-08-28 5871/week @ 2024-09-04 5310/week @ 2024-09-11 4691/week @ 2024-09-18 6996/week @ 2024-09-25 5158/week @ 2024-10-02

23,222 downloads per month
Used in 29 crates (6 directly)

MIT/Apache

61KB
1K SLoC

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.56 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
~20K SLoC