':param iv: init vector
:param alg: cipher algorithm
:return: A Cipher instance'

def build_cipher(self, iv='', alg='aes_128_cbc'):

    (typ, bits, cmode) = alg.split('_')
    if (not iv):
        if self.iv:
            iv = self.iv
        else:
            iv = Random.new().read(AES.block_size)
    else:
        assert (len(iv) == AES.block_size)
    if (bits not in ['128', '192', '256']):
        raise Exception('Unsupported    key    length')
    try:
        assert (len(self.key) == (int(bits) >> 3))
    except AssertionError:
        raise Exception('Wrong    Key    length')
    try:
        return (AES.new(self.key, POSTFIX_MODE[cmode], iv), iv)
    except KeyError:
        raise Exception('Unsupported    chaining    mode')
