fn cipher_with<F>(key: &[u8], input: &[u8], func: F) -> Vec<u8>
    where F: Fn(&Blowfish, &[u8], &mut [u8])
{

    let blowfish = Blowfish::new(key);
    let block_size = <Blowfish as BlockEncryptor>::block_size(&blowfish);

    // Input and output bytes
    let input_len = round_len(input.len(), block_size);
    let mut input = input.to_vec();
    input.resize(input_len, PADDING_BYTE);

    let mut output: Vec<u8> = Vec::with_capacity(input_len);
    unsafe {
        output.set_len(input_len);
    }

    // Encrypts input and into output
    for (ichunk, mut ochunk) in input.chunks(block_size).zip(output.chunks_mut(block_size)) {
        func(&blowfish, ichunk, ochunk);
    }

    output
}
/// Divides the input in blocks and ciphers it using the given closure.
Divides the input in blocks and ciphers it using the given closure.
Divides the input in blocks and ciphers it using the given closure .
fn cipher_with<F>(key: &[u8], input: &[u8], func: F) -> Vec<u8>
    where F: Fn(&Blowfish, &[u8], &mut [u8])
{
    let blowfish = Blowfish::new(key);
    let block_size = <Blowfish as BlockEncryptor>::block_size(&blowfish);
    // Input and output bytes
    let input_len = round_len(input.len(), block_size);
    let mut input = input.to_vec();
    input.resize(input_len, PADDING_BYTE);
    let mut output: Vec<u8> = Vec::with_capacity(input_len);
    unsafe {
        output.set_len(input_len);
    }
    // Encrypts input and into output
    for (ichunk, mut ochunk) in input.chunks(block_size).zip(output.chunks_mut(block_size)) {
        func(&blowfish, ichunk, ochunk);
    }
    output
}
fn cipher_with < F > ( key : & [ u8 ] , input : & [ u8 ] , func : F ) -> Vec < u8 > where F : Fn ( & Blowfish , & [ u8 ] , & mut [ u8 ] ) { let blowfish = Blowfish :: new ( key ) ; let block_size = < Blowfish as BlockEncryptor > :: block_size ( & blowfish ) ; // Input and output bytes let input_len = round_len ( input . len ( ) , block_size ) ; let mut input = input . to_vec ( ) ; input . resize ( input_len , PADDING_BYTE ) ; let mut output : Vec < u8 > = Vec :: with_capacity ( input_len ) ; unsafe { output . set_len ( input_len ) ; } // Encrypts input and into output for ( ichunk , mut ochunk ) in input . chunks ( block_size ) . zip ( output . chunks_mut ( block_size ) ) { func ( & blowfish , ichunk , ochunk ) ; } output }
Divides the input in blocks and ciphers it using the given closure.
Divides the input in blocks and ciphers it using the given closure .
key
&[u8]
input
&[u8]
func
F
key
&[u8]
input
&[u8]
func
F