// Convert read bytes to a Vector of 64-bit values, optionally
// including ANSI X9.23 padding (for the encryption case).
Convert read bytes to a Vector of 64-bit values, optionally
including ANSI X9.23 padding (for the encryption case).
Convert read bytes to a Vector of 64 - bit values optionally including ANSI X9 . 23 padding ( for the encryption case ) .
fn prepare_input(data: &Vec<u8>, add_padding: bool) -> Vec<u64> {
    let num_pad_bytes = match add_padding {
        true => 8 - (data.len() % 8),
        false => 0,
    };
    let mut result: Vec<u64> = Vec::with_capacity((data.len() / 8) + 8);
    let mut buf: u64 = 0;
    let mut rng = rand::thread_rng();
    for i in 0..(data.len() + num_pad_bytes) {
        buf <<= 8;
        if i < data.len() {
            buf |= data[i] as u64;
        } else if i == data.len() + num_pad_bytes - 1 {
            buf |= num_pad_bytes as u64;
        } else {
            buf |= rng.gen_range(0, 255);
        }
        if i % 8 == 7 {
            result.push(buf);
            buf = 0;
        }
    }
    return result;
}
fn prepare_input ( data : & Vec < u8 > , add_padding : bool ) -> Vec < u64 > { let num_pad_bytes = match add_padding { true => 8 - ( data . len ( ) % 8 ) , false => 0 , } ; let mut result : Vec < u64 > = Vec :: with_capacity ( ( data . len ( ) / 8 ) + 8 ) ; let mut buf : u64 = 0 ; let mut rng = rand :: thread_rng ( ) ; for i in 0 .. ( data . len ( ) + num_pad_bytes ) { buf <<= 8 ; if i < data . len ( ) { buf |= data [ i ] as u64 ; } else if i == data . len ( ) + num_pad_bytes - 1 { buf |= num_pad_bytes as u64 ; } else { buf |= rng . gen_range ( 0 , 255 ) ; } if i % 8 == 7 { result . push ( buf ) ; buf = 0 ; } } return result ; }
Convert read bytes to a Vector of 64-bit values, optionally
including ANSI X9.23 padding (for the encryption case).
Convert read bytes to a Vector of 64 - bit values optionally including ANSI X9 . 23 padding ( for the encryption case ) .
data
&Vec<u8>
add_padding
bool