当然可以啊,这个问题很简单啊,
a.rar --> a.tmp   //加密
del a.rar
ren a.tmp a.rara.rar --> a.tmp   //还原
del a.rar
ren a.tmp a.rar 就可以打开 a.rar 了啊。

解决方案 »

  1.   

    其实你可以对他进行DES加密啊,用TripelDES算法,对每个要压缩的文件进行加密,然后再对密文进行压缩,而密钥可以作为CRC循环交错码的某种变形。这样你就可以保证自己的文件是安全的了。还有一种方法就是对压缩好的文件进行加密,不让别人进行解密。这样别人肯定是无法对这个文件进行解密的。JAVA里有专门的DES类,但是最好是自己写一个适合自己公司用的。那样更加安全一点。否则别人也知道那个类得到了你的密钥就麻烦了。你可以考虑一下这个方法。其他的加密方法也可以用,比如ARS什么的
      

  2.   

    对了,如果对压缩的CRC验证码进行加密的话可能效率会高点,因为加密的只是很短的字符串,在WAR不知道正确的CRC码时他是不会对这个文件进行解压缩的。
      

  3.   

    To Frank1982(米能达)
    谢谢了,我只是想把压缩好的文件打乱,即使别人得到文件,解压缩。得到的也是不正常显示的文件,保密效果就达到了。我对文件加密不太了解,现在所想的也只是最简单的打乱文件内容而已!你所谓的的DES加密以及TripelDESs算法我都不太了解!对压缩的CRC验证码加密这种方法我考虑过,不过经理不同意!
      

  4.   

    关于使用DES算法你可以去这里看看
    http://www-900.ibm.com/developerWorks/cn/java/l-secureclass/index.shtml
      

  5.   

    或者我给你一段运用DES的代码
    import java.security.*;
    import javax.crypto.*;public class Crypt
    {    private static String Algorithm = "DES"; //定义 加密算法,可用 DES,DESede,Blowfish    static boolean debug = false;    static
        {
            Security.addProvider(new com.sun.crypto.provider.SunJCE());
        }    //生成密钥, 注意此步骤时间比较长
        public static byte[] getKey()
            throws Exception
        {
            KeyGenerator keygen = KeyGenerator.getInstance(Algorithm);
            SecretKey deskey = keygen.generateKey();
            if (debug)
                System.out.println("生成密钥:" + byte2hex(deskey.getEncoded()));
            return deskey.getEncoded();
        }    //加密
        public static byte[] encode(byte[] input, byte[] key)
            throws Exception
        {
            SecretKey deskey = new javax.crypto.spec.SecretKeySpec(key, Algorithm);
            if (debug)
            {
                System.out.println("加密前的二进串:" + byte2hex(input));
                System.out.println("加密前的字符串:" + new String(input));
            }
            Cipher c1 = Cipher.getInstance(Algorithm);
            c1.init(Cipher.ENCRYPT_MODE, deskey);
            byte[] cipherByte = c1.doFinal(input);
            if (debug)
                System.out.println("加密后的二进串:" + byte2hex(cipherByte));
            return cipherByte;
        }    //解密
        public static byte[] decode(byte[] input, byte[] key)
            throws Exception
        {
            SecretKey deskey = new javax.crypto.spec.SecretKeySpec(key, Algorithm);
            if (debug)
                System.out.println("解密前的信息:" + byte2hex(input));
            Cipher c1 = Cipher.getInstance(Algorithm);
            c1.init(Cipher.DECRYPT_MODE, deskey);
            byte[] clearByte = c1.doFinal(input);
            if (debug)
            {
                System.out.println("解密后的二进串:" + byte2hex(clearByte));
                System.out.println("解密后的字符串:" + (new String(clearByte)));
            }
            return clearByte;
        }    //md5()信息摘要, 不可逆
        public static byte[] md5(byte[] input)
            throws Exception
        {
            java.security.MessageDigest alg = java.security.MessageDigest.
                getInstance("MD5"); //or "SHA-1"
            if (debug)
            {
                System.out.println("摘要前的二进串:" + byte2hex(input));
                System.out.println("摘要前的字符串:" + new String(input));
            }
            alg.update(input);
            byte[] digest = alg.digest();
            if (debug)
                System.out.println("摘要后的二进串:" + byte2hex(digest));
            return digest;
        }    //字节码转换成16进制字符串
        public static String byte2hex(byte[] b)
        {
            String hs = "";
            String stmp = "";
            for (int n = 0; n < b.length; n++)
            {
                stmp = (java.lang.Integer.toHexString(b[n] & 0XFF));
                if (stmp.length() == 1)
                    hs = hs + "0" + stmp;
                else
                    hs = hs + stmp;
                if (n < b.length - 1)
                    hs = hs + ":";
            }
            return hs.toUpperCase();
        }
    /*
        public static void main(String[] args)
            throws Exception
        {
            debug = true;
    //    byte[] key = getKey();
            byte[] key = "好好学习".getBytes();
            decode(encode("测试加密".getBytes(), key), key);
            md5("测试加密".getBytes());
        }
    */
    }
      

  6.   

    http://www.aci.net/kalliste/des.htm
    DES算法这里有非常详细的描述。看懂了就可以写了!呵呵多打开几次就可以了
      

  7.   

    谢谢诸位了!我使用了jct,但以后会研究一下DES!