public int encryptFile(String file, String destFile, String encryptType) {
        int result = 0;
        try {
            Cipher cipher = getPattern(encryptType, ENCRYPT_MODE);
            InputStream is = new FileInputStream(file);
            OutputStream out = new FileOutputStream(destFile);
            CipherInputStream cis = new CipherInputStream(is, cipher);
            byte[] buffer = new byte[1024];
            int r;
            while ((r = cis.read(buffer)) > 0) {
                out.write(buffer, 0, r);
            }
            cis.close();
            is.close();
            out.close();
            result = 1;
        } catch (FileNotFoundException e) {
            result = 5;
        } catch (Exception e) {
            throw new RuntimeException(e);
        }
        return result;
    }
The file file is encrypted and saved in the target file destFile.
@param file The file to be encrypted such as c:/test/file.txt
@param destFile The name of the file stored after encryption, such as c:/ encrypted file .txt
@param encryptType encryption mode (ECB/CBC/OFB/CFB)
@return Encryption result 0: Abnormal 1: Encryption successful; 5: File to be encrypted not found
@author sucb
@date March 2, 2017 7:56:08 pm
chat2db-server/chat2db-server-domain/chat2db-server-domain-core/src/main/java/ai/chat2db/server/domain/core/util/DesUtil.java