def _encrypt(cipher, key, data, iv, padding):
if not isinstance(key, byte_cls):<EOL><INDENT>raise TypeError(pretty_message(<EOL>'''<STR_LIT>''',<EOL>type_name(key)<EOL>))<EOL><DEDENT>if not isinstance(data, byte_cls):<EOL><INDENT>raise TypeError(pretty_message(<EOL>'''<STR_LIT>''',<EOL>type_name(data)<EOL>))<EOL><DEDENT>if cipher != '<STR_LIT>' and not isinstance(iv, byte_cls):<EOL><INDENT>raise TypeError(pretty_message(<EOL>'''<STR_LIT>''',<EOL>type_name(iv)<EOL>))<EOL><DEDENT>if cipher != '<STR_LIT>' and not padding:<EOL><INDENT>raise ValueError('<STR_LIT>')<EOL><DEDENT>if _backend == '<STR_LIT>':<EOL><INDENT>return _advapi32_encrypt(cipher, key, data, iv, padding)<EOL><DEDENT>return _bcrypt_encrypt(cipher, key, data, iv, padding)<EOL>
Encrypts plaintext

:param cipher:
    A unicode string of "aes", "des", "tripledes_2key", "tripledes_3key",
    "rc2", "rc4"

:param key:
    The encryption key - a byte string 5-16 bytes long

:param data:
    The plaintext - a byte string

:param iv:
    The initialization vector - a byte string - unused for RC4

:param padding:
    Boolean, if padding should be used - unused for RC4

: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 byte string of the ciphertext