0.4.0 |
|
---|
#4 in #ff1
Used in binary-ff1-aes-v07
41KB
808 lines
fpe
This crate contains pure-Rust implementations of format-preserving encryption algorithms.
The following algorithms are implemented:
- FF1 (specified in NIST Special Publication 800-38G).
This crate requires Rust version 1.49 or greater.
License
Licensed under either of
- Apache License, Version 2.0, (LICENSE-APACHE or http://www.apache.org/licenses/LICENSE-2.0)
- MIT license (LICENSE-MIT or http://opensource.org/licenses/MIT)
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
~24K SLoC