@@ -0,0 +1,2224 @@
+package com.maxiee.heartbeat.backup;%0A%0Aimport java.io.ByteArrayOutputStream;%0Aimport java.io.File;%0Aimport java.io.FileInputStream;%0Aimport java.io.FileOutputStream;%0Aimport java.io.InputStream;%0Aimport java.io.OutputStream;%0Aimport java.security.Key;%0A%0Aimport javax.crypto.Cipher;%0Aimport javax.crypto.CipherInputStream;%0Aimport javax.crypto.spec.SecretKeySpec;%0A%0A/**%0A * Created by maxiee on 15-8-12.%0A */%0Apublic class FileDES %7B%0A    private final static String KEY_RULE = %22maxieejudy%22;%0A    private final static int LENGTH_OF_SQLITE_MAGIC_NUMBER = 15;%0A    private final static String SQLITE_MAGIC_NUMBER = %22SQLite format 3%22;%0A%0A    private static Key initKey() %7B%0A        byte%5B%5D keyByte = KEY_RULE.getBytes();%0A        byte%5B%5D byteTemp = new byte%5B8%5D;%0A        for (int i=0; i%3CbyteTemp.length && i%3CkeyByte.length; i++) %7B%0A            byteTemp%5Bi%5D = keyByte%5Bi%5D;%0A        %7D%0A        return new SecretKeySpec(byteTemp, %22DES%22);%0A    %7D%0A%0A    public static void doEncryptFile(File in, File out) %7B%0A        if (in == null) return;%0A        try %7B%0A            Cipher encryptCipher = Cipher.getInstance(%22DES%22);%0A            encryptCipher.init(Cipher.ENCRYPT_MODE, initKey());%0A            FileInputStream is = new FileInputStream(in);%0A            CipherInputStream cin = new CipherInputStream(is, encryptCipher);%0A            OutputStream os = new FileOutputStream(out);%0A            byte%5B%5D buffer = new byte%5B1024%5D;%0A            int len;%0A            while ((len=cin.read(buffer)) %3E 0) %7B%0A                os.write(buffer, 0, len);%0A                os.flush();%0A            %7D%0A            os.close();%0A            cin.close();%0A            is.close();%0A        %7D catch (Exception e) %7Be.printStackTrace();%7D%0A    %7D%0A%0A    public static boolean doDecryptFile (InputStream in, OutputStream os) throws Exception%7B%0A        if (in == null) return false;%0A        Cipher decryptCipher = Cipher.getInstance(%22DES%22);%0A        decryptCipher.init(Cipher.DECRYPT_MODE, initKey());%0A        CipherInputStream cin = new CipherInputStream(in, decryptCipher);%0A        byte%5B%5D buffer = new byte%5B1024%5D;%0A        int len;%0A        while ((len=cin.read(buffer)) %3E 0) %7B%0A            os.write(buffer, 0, len);%0A        %7D%0A        cin.close();%0A        in.close();%0A        os.close();%0A        return true;%0A    %7D%0A%7D%0A

backup file encryption.