'CBC block encryption, IV is set with \'encrypt\''

def encryptBlock(self, plainTextBlock):

    auto_IV = ''
    if (self.encryptBlockCount == 0):
        if (self.iv == None):
            self.iv = ''.join([chr(self.r.randrange(256)) for i in range(self.blockSize)])
            self.prior_encr_CT_block = self.iv
            auto_IV = self.prior_encr_CT_block
        else:
            assert (len(self.iv) == self.blockSize), 'IV    must    be    same    length    as    block'
            self.prior_encr_CT_block = self.iv
    '    encrypt    the    prior    CT    XORed    with    the    PT    '
    ct = self.baseCipher.encryptBlock(xor(self.prior_encr_CT_block, plainTextBlock))
    self.prior_encr_CT_block = ct
    return (auto_IV + ct)
