pub fn encrypt(self, key: &[u8], plaintext: &[u8]) -> Result<Vec<u8>> {
        info!("encrypt unprotected");

        let iv_vec = vec![0u8; self.block_size()];

        let bs = self.block_size();
        let mut rng = thread_rng();

        let prefix_len = bs + 2;
        let plaintext_len = plaintext.len();

        let mut ciphertext = vec![0u8; prefix_len + plaintext_len];
        // prefix
        rng.fill_bytes(&mut ciphertext[..bs]);

        // add quick check
        ciphertext[bs] = ciphertext[bs - 2];
        ciphertext[bs + 1] = ciphertext[bs - 1];

        // plaintext
        ciphertext[prefix_len..].copy_from_slice(plaintext);

        self.encrypt_with_iv(key, &iv_vec, &mut ciphertext, true)?;

        Ok(ciphertext)
    }
/// Encrypt the data using CFB mode, without padding. Overwrites the input.
/// Uses an IV of all zeroes, as specified in the openpgp cfb mode.
Encrypt the data using CFB mode, without padding. Overwrites the input.
Uses an IV of all zeroes, as specified in the openpgp cfb mode.
Encrypt the data using CFB mode without padding . Overwrites the input . Uses an IV of all zeroes as specified in the openpgp cfb mode .
pub fn encrypt(self, key: &[u8], plaintext: &[u8]) -> Result<Vec<u8>> {
        info!("encrypt unprotected");
        let iv_vec = vec![0u8; self.block_size()];
        let bs = self.block_size();
        let mut rng = thread_rng();
        let prefix_len = bs + 2;
        let plaintext_len = plaintext.len();
        let mut ciphertext = vec![0u8; prefix_len + plaintext_len];
        // prefix
        rng.fill_bytes(&mut ciphertext[..bs]);
        // add quick check
        ciphertext[bs] = ciphertext[bs - 2];
        ciphertext[bs + 1] = ciphertext[bs - 1];
        // plaintext
        ciphertext[prefix_len..].copy_from_slice(plaintext);
        self.encrypt_with_iv(key, &iv_vec, &mut ciphertext, true)?;
        Ok(ciphertext)
    }
pub fn encrypt ( self , key : & [ u8 ] , plaintext : & [ u8 ] ) -> Result < Vec < u8 > > { info ! ( " " ) ; let iv_vec = vec ! [ 0u8 self block_size ( ) ] ; let bs = self . block_size ( ) ; let mut rng = thread_rng ( ) ; let prefix_len = bs + 2 ; let plaintext_len = plaintext . len ( ) ; let mut ciphertext = vec ! [ 0u8 prefix_len plaintext_len ] ; // prefix rng . fill_bytes ( & mut ciphertext [ .. bs ] ) ; // add quick check ciphertext [ bs ] = ciphertext [ bs - 2 ] ; ciphertext [ bs + 1 ] = ciphertext [ bs - 1 ] ; // plaintext ciphertext [ prefix_len .. ] . copy_from_slice ( plaintext ) ; self . encrypt_with_iv ( key , & iv_vec , & mut ciphertext , true ) ? ; Ok ( ciphertext ) }
Encrypt the data using CFB mode, without padding.
Encrypt the data using CFB mode without padding .
self
key
&[u8]
plaintext
&[u8]
self
key
&[u8]
plaintext
&[u8]