This library provides a FieldEcryption
struct that allows values in an input format to be encrypted into values in an output format, where the input and out put formats are described by regular expressions. So it is similar to a Format Preserving Encryption scheme but allows for flexibility in the format of the encrypted fields.
```rust use field_encryption::FieldEncryption;
let fe = FieldEncryption::new(r"[A-Z][a-z]{1,4} [A-Z][a-z]{1-4}!", r"[a-z]{5} [a-z]{7}", &[0;32]).unwrap(); let ciphertext = fe.encrypt("Hello World!").unwrap(); println!("{}", ciphertext); let plaintext = fe.decrypt(&ciphertext).unwrap(); println!("{}", plain_text); ```
Gives the output:
text
qtzwe mcdzozq
Hello World!
The implementation is based on the 'Ciphers with Arbitrary Finite Domains' paper by Black and Rogaway (2002), and works as follows: