1.加密的目的

不让其他类加载器可以加载我们的测试类,只有我们自己的加载器可以加载我们的类。

2.加密解密方法

没有统一,需要开发者自定义

3.加密示例

public class MyDemo {

    public static void main(String[] args){
        String srcPath  = args[0];
        String destPath = args[1];
        try{
            FileInputStream fileInputStream = new FileInputStream(srcPath);
            FileOutputStream fileOutputStream = new FileOutputStream(destPath);
            cypher(fileInputStream, fileOutputStream);
            fileInputStream.close();
            fileOutputStream.close();
        }catch (Exception e){
            e.printStackTrace();
        }

    }

    private static void cypher(InputStream inputStream, OutputStream outputStream){
        int b = -1;
        try{
            while ((b = inputStream.read()) != -1){
                outputStream.write(b ^ 0xff);
            }
        }catch (Exception e){
         e.printStackTrace();
        }

    }
}

results matching ""

    No results matching ""