/// Encrypts aes 128 in ecb.
Encrypts aes 128 in ecb.
Encrypts aes 128 in ecb .
pub fn encrypt_aes_128_ecb(
    b: &[u8],
    k: &[u8],
) -> Result<Vec<u8>, symmetriccipher::SymmetricCipherError> {
    // pad input.
    let b = &crate::padding::pkcs7(b, 16);
    let mut encryptor = aes::ecb_encryptor(aes::KeySize::KeySize128, k, blockmodes::NoPadding);
    let mut final_result = Vec::<u8>::new();
    let mut read_buffer = buffer::RefReadBuffer::new(b);
    let mut buffer = [0; 4096];
    let mut write_buffer = buffer::RefWriteBuffer::new(&mut buffer);
    loop {
        let result = encryptor.encrypt(&mut read_buffer, &mut write_buffer, true)?;
        final_result.extend(
            write_buffer
                .take_read_buffer()
                .take_remaining()
                .iter()
                .map(|&i| i),
        );
        match result {
            BufferResult::BufferUnderflow => break,
            BufferResult::BufferOverflow => {}
        }
    }
    Ok(final_result)
}
pub fn encrypt_aes_128_ecb ( b : & [ u8 ] , k : & [ u8 ] , ) -> Result < Vec < u8 > , symmetriccipher :: SymmetricCipherError > { // pad input. let b = & crate :: padding :: pkcs7 ( b , 16 ) ; let mut encryptor = aes :: ecb_encryptor ( aes :: KeySize :: KeySize128 , k , blockmodes :: NoPadding ) ; let mut final_result = Vec :: < u8 > :: new ( ) ; let mut read_buffer = buffer :: RefReadBuffer :: new ( b ) ; let mut buffer = [ 0 ; 4096 ] ; let mut write_buffer = buffer :: RefWriteBuffer :: new ( & mut buffer ) ; loop { let result = encryptor . encrypt ( & mut read_buffer , & mut write_buffer , true ) ? ; final_result . extend ( write_buffer . take_read_buffer ( ) . take_remaining ( ) . iter ( ) . map ( | & i | i ) , ) ; match result { BufferResult :: BufferUnderflow => break , BufferResult :: BufferOverflow => { } } } Ok ( final_result ) }
Encrypts aes 128 in ecb.
Encrypts aes 128 in ecb .
b
&[u8]
<not_specific>
k
&[u8]
<not_specific>