def aes_cbc_no_padding_encrypt(key, data, iv):
    """
    Encrypts plaintext using AES in CBC mode with a 128, 192 or 256 bit key and
    no padding. This means the ciphertext must be an exact multiple of 16 bytes
    long.

    :param key:
        The encryption key - a byte string either 16, 24 or 32 bytes long

    :param data:
        The plaintext - a byte string

    :param iv:
        The initialization vector - either a byte string 16-bytes long or None
        to generate an IV

    :raises:
        ValueError - when any of the parameters contain an invalid value
        TypeError - when any of the parameters are of the wrong type
        OSError - when an error is returned by the OS crypto library

    :return:
        A tuple of two byte strings (iv, ciphertext)
    """

    if len(key) not in [16, 24, 32]:
        raise ValueError(pretty_message(
            '''
            key must be either 16, 24 or 32 bytes (128, 192 or 256 bits)
            long - is %s
            ''',
            len(key)
        ))

    if not iv:
        iv = rand_bytes(16)
    elif len(iv) != 16:
        raise ValueError(pretty_message(
            '''
            iv must be 16 bytes long - is %s
            ''',
            len(iv)
        ))

    if len(data) % 16 != 0:
        raise ValueError(pretty_message(
            '''
            data must be a multiple of 16 bytes long - is %s
            ''',
            len(data)
        ))

    return (iv, _encrypt('aes', key, data, iv, False))
def aes_cbc_no_padding_encrypt(key, data, iv):
    

    if len(key) not in [16, 24, 32]:
        raise ValueError(pretty_message(
            ,
            len(key)
        ))

    if not iv:
        iv = rand_bytes(16)
    elif len(iv) != 16:
        raise ValueError(pretty_message(
            ,
            len(iv)
        ))

    if len(data) % 16 != 0:
        raise ValueError(pretty_message(
            ,
            len(data)
        ))

    return (iv, _encrypt('aes', key, data, iv, False))
def aes_cbc_no_padding_encrypt ( key , data , iv ) : if len ( key ) not in [ 16 , 24 , 32 ] : raise ValueError ( pretty_message ( '''
            key must be either 16, 24 or 32 bytes (128, 192 or 256 bits)
            long - is %s
            ''' , len ( key ) ) ) if not iv : iv = rand_bytes ( 16 ) elif len ( iv ) != 16 : raise ValueError ( pretty_message ( '''
            iv must be 16 bytes long - is %s
            ''' , len ( iv ) ) ) if len ( data ) % 16 != 0 : raise ValueError ( pretty_message ( '''
            data must be a multiple of 16 bytes long - is %s
            ''' , len ( data ) ) ) return ( iv , _encrypt ( 'aes' , key , data , iv , False ) )
Encrypts plaintext using AES in CBC mode with a 128, 192 or 256 bit key and
    no padding. This means the ciphertext must be an exact multiple of 16 bytes
    long.

    :param key:
        The encryption key - a byte string either 16, 24 or 32 bytes long

    :param data:
        The plaintext - a byte string

    :param iv:
        The initialization vector - either a byte string 16-bytes long or None
        to generate an IV

    :raises:
        ValueError - when any of the parameters contain an invalid value
        TypeError - when any of the parameters are of the wrong type
        OSError - when an error is returned by the OS crypto library

    :return:
        A tuple of two byte strings (iv, ciphertext)
Encrypts plaintext using AES in CBC mode with a 128 192 or 256 bit key and no padding . This means the ciphertext must be an exact multiple of 16 bytes long .