def encrypt(self, data, pad=None, padmode=None):
ENCRYPT = des.ENCRYPT<EOL>DECRYPT = des.DECRYPT<EOL>data = self._guardAgainstUnicode(data)<EOL>if pad is not None:<EOL><INDENT>pad = self._guardAgainstUnicode(pad)<EOL><DEDENT>data = self._padData(data, pad, padmode)<EOL>if self.getMode() == CBC:<EOL><INDENT>self.__key1.setIV(self.getIV())<EOL>self.__key2.setIV(self.getIV())<EOL>self.__key3.setIV(self.getIV())<EOL>i = <NUM_LIT:0><EOL>result = []<EOL>while i < len(data):<EOL><INDENT>block = self.__key1.crypt(data[i:i+<NUM_LIT:8>], ENCRYPT)<EOL>block = self.__key2.crypt(block, DECRYPT)<EOL>block = self.__key3.crypt(block, ENCRYPT)<EOL>self.__key1.setIV(block)<EOL>self.__key2.setIV(block)<EOL>self.__key3.setIV(block)<EOL>result.append(block)<EOL>i += <NUM_LIT:8><EOL><DEDENT>if _pythonMajorVersion < <NUM_LIT:3>:<EOL><INDENT>return '<STR_LIT>'.join(result)<EOL><DEDENT>else:<EOL><INDENT>return bytes.fromhex('<STR_LIT>').join(result)<EOL><DEDENT><DEDENT>else:<EOL><INDENT>data = self.__key1.crypt(data, ENCRYPT)<EOL>data = self.__key2.crypt(data, DECRYPT)<EOL>return self.__key3.crypt(data, ENCRYPT)<EOL><DEDENT>
encrypt(data, [pad], [padmode]) -> bytes

        data : bytes to be encrypted
        pad  : Optional argument for encryption padding. Must only be one byte
        padmode : Optional argument for overriding the padding mode.

        The data must be a multiple of 8 bytes and will be encrypted
        with the already specified key. Data does not have to be a
        multiple of 8 bytes if the padding character is supplied, or
        the padmode is set to PAD_PKCS5, as bytes will then added to
        ensure the be padded data is a multiple of 8 bytes.