pub struct FPE { /* private fields */ }Expand description
Represents an instance of format preserving encryption
§Examples
use std::str::FromStr;
let modulus = botan::MPI::from_str("1000000000").unwrap();
let key = vec![0; 32];
let rounds = 16;
let compat_mode = false;
let fpe = botan::FPE::new_fe1(&modulus, &key, rounds, compat_mode).unwrap();
let input = botan::MPI::from_str("9392024").unwrap();
let tweak = vec![1,2,3,4,5];
let ctext = fpe.encrypt(&input, &tweak).unwrap();
assert!(ctext < modulus);
let ptext = fpe.decrypt(&ctext, &tweak).unwrap();
assert_eq!(ptext, input);Implementations§
Source§impl FPE
impl FPE
Sourcepub fn new_fe1(
modulus: &MPI,
key: &[u8],
rounds: usize,
compat_mode: bool,
) -> Result<FPE>
pub fn new_fe1( modulus: &MPI, key: &[u8], rounds: usize, compat_mode: bool, ) -> Result<FPE>
Create a new FPE instance, FE1 scheme Rounds should be 16 or higher for best security
Trait Implementations§
Auto Trait Implementations§
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more