def des_cbc_pkcs5_encrypt(key, data, iv):
if len(key) != <NUM_LIT:8>:<EOL><INDENT>raise ValueError(pretty_message(<EOL>'''<STR_LIT>''',<EOL>len(key)<EOL>))<EOL><DEDENT>if not iv:<EOL><INDENT>iv = rand_bytes(<NUM_LIT:8>)<EOL><DEDENT>elif len(iv) != <NUM_LIT:8>:<EOL><INDENT>raise ValueError(pretty_message(<EOL>'''<STR_LIT>''',<EOL>len(iv)<EOL>))<EOL><DEDENT>return (iv, _encrypt('<STR_LIT>', key, data, iv, True))<EOL>
Encrypts plaintext using DES in CBC mode with a 56 bit key and PKCS#5
padding.

:param key:
    The encryption key - a byte string 8 bytes long (includes error correction bits)

:param data:
    The plaintext - a byte string

:param iv:
    The initialization vector - a byte string 8-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 OpenSSL

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