':param key: The encryption key
:param iv: init vector
:param msg: Message to be encrypted
:param padding: Which padding that should be used
:param b64enc: Whether the result should be base64encoded
:param block_size: If PKCS#7 padding which block size to use
:return: The encrypted message'

def encrypt(self, msg, iv=None, alg='aes_128_cbc', padding='PKCS#7', b64enc=True, block_size=BLOCK_SIZE):

    if (padding == 'PKCS#7'):
        _block_size = block_size
    elif (padding == 'PKCS#5'):
        _block_size = 8
    else:
        _block_size = 0
    if _block_size:
        plen = (_block_size - (len(msg) % _block_size))
        c = chr(plen)
        msg += (c * plen)
    (cipher, iv) = self.build_cipher(iv, alg)
    cmsg = (iv + cipher.encrypt(msg))
    if b64enc:
        return b64encode(cmsg)
    else:
        return cmsg
