'Encrypt data with the key and the parameters set at initialization.
The cipher object is stateful; encryption of a long block
of data can be broken up in two or more calls to `encrypt()`.
That is, the statement:
>>> c.encrypt(a) + c.encrypt(b)
is always equivalent to:
>>> c.encrypt(a+b)
That also means that you cannot reuse an object for encrypting
or decrypting other data with the same key.
This function does not perform any padding.
- For `MODE_ECB`, `MODE_CBC`, and `MODE_OFB`, *plaintext* length
(in bytes) must be a multiple of *block_size*.
- For `MODE_CFB`, *plaintext* length (in bytes) must be a multiple
of *segment_size*/8.
- For `MODE_CTR`, *plaintext* can be of any length.
- For `MODE_OPENPGP`, *plaintext* must be a multiple of *block_size*,
unless it is the last chunk of the message.
:Parameters:
plaintext : byte string
The piece of data to encrypt.
:Return:
the encrypted data, as a byte string. It is as long as
*plaintext* with one exception: when encrypting the first message
chunk with `MODE_OPENPGP`, the encypted IV is prepended to the
returned ciphertext.'

def encrypt(self, plaintext):

    if (self.mode == MODE_OPENPGP):
        padding_length = ((self.block_size - (len(plaintext) % self.block_size)) % self.block_size)
        if (padding_length > 0):
            if self._done_last_block:
                raise ValueError('Only    the    last    chunk    is    allowed    to    have    length    not    multiple    of    %d    bytes', self.block_size)
            self._done_last_block = True
            padded = (plaintext + (b('\x00') * padding_length))
            res = self._cipher.encrypt(padded)[:len(plaintext)]
        else:
            res = self._cipher.encrypt(plaintext)
        if (not self._done_first_block):
            res = (self._encrypted_IV + res)
            self._done_first_block = True
        return res
    return self._cipher.encrypt(plaintext)
