Java绿盾解密- Ldterm(绿盾加密文件解密)

编程入门 行业动态 更新时间:2024-10-28 08:26:45

废话不多说,直接上代码

直接运行 main,解密后的文件均在 replace 路径下(如本代码中:D:/pierced/windows_641-新副本)

package com.example.demologin;


import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.InputStream;
import java.text.DecimalFormat;

/**
 * @Classname: Decrypt
 * @Version:V1.0
 */
public class Decrypt {


    //待解密的文件夹路径
    private static String rootFolderPath = getFullpath("D:","\\pierced\\windows_641");
    //待解密文件夹路径中的文件夹
    private static String beReplaced = "windows_641";
    
    private static String replace = beReplaced + "-新副本";
    //被替换的文件夹

    //解密文件数
    private static Integer fileCount = 0;
    //解密文件大小
    private static Long fileSize = new Long(0);

    public static void main(String[] args) {
        try {
            Long startTime = System.currentTimeMillis();
            decryptFolder(new File(rootFolderPath));
            System.out.println("------------------------------------------------------------------------------------------------");
            System.out.print("解密完成,共计耗时:"+new DecimalFormat("0.00").format((double)(System.currentTimeMillis()-startTime)/1000)+"s");
            System.out.print("\t共计文件:"+fileCount+"个");
            System.out.print("\t共计文件大小:"+new DecimalFormat(",##0.00").format((double)fileSize/1024/1024/1024)+"GB");
            System.out.print(" = "+new DecimalFormat(",##0.00").format((double)fileSize/1024/1024)+"mb");
            System.out.println(" = "+new DecimalFormat(",##0.00").format((double)fileSize/1024)+"kb");
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    /**
     * @Methodname: getFullpath
     * @Discription: TODO 拼接完整的路径  根据操作系统拼接连接符
     * @param dir 路径
     * @return
     */
    private static String getFullpath(String... dir){
        StringBuffer fullPath = new StringBuffer("");
        for (int i = 0; i < dir.length; i++) {
            fullPath.append(dir[i]);
            if (dir.length-1!=i) {
                fullPath.append(File.separator);
            }
        }
        return fullPath.toString();
    }

    /**
     * @Methodname: decryptFolder
     * @Discription: TODO 解密整个文件夹
     * @param folder 文件夹
     * @throws Exception
     */
    private static void decryptFolder(File folder)throws Exception {
        if (!folder.isDirectory()) {
            return;
        }
        File[] files = folder.listFiles();
        for (File file : files) {
            if (file.isFile()) {
                //进行解密操作
                decryptFile(file);
                fileCount ++;
                fileSize += file.length();
                continue ;
            }
            //创建文件夹
            File childFolder =new File(getFullpath(folder.getPath(),file.getName()));
            File newChilFolder =new File(childFolder.getPath().replaceFirst(beReplaced,replace));
            if (newChilFolder.exists()) {
                newChilFolder.delete();
            }
            newChilFolder.mkdir();
            //进行递归
            decryptFolder(childFolder);
        }
    }

    private static void decryptFile(File file){
        try {
            File newFile = new File(file.getPath().replaceFirst(beReplaced,replace));
            if (newFile.exists()) {
                newFile.delete();
            }
            File newFile1 = new File(newFile.getParent());
            newFile1.mkdir();
            newFile.createNewFile();
            FileOutputStream output = new FileOutputStream(newFile);
            InputStream input = new FileInputStream(file);
            int length = -1;
            byte[] _byte = new byte[8000];
            System.out.println(file.getPath());
            int sum = input.available();
            System.out.print("文件名:"+file.getPath());
            System.out.print("\t文件大小:"+new DecimalFormat("0.00").format((double)file.length()/1024)+"kb");
            System.out.print("\t已解密大小:"+new DecimalFormat("0.00").format((double)(file.length()-input.available())/1024)+"kb");
            System.out.println("\t已解密比例:"+(sum==0?"100%":new DecimalFormat("0.00%").format((double)(sum-input.available())/sum))+"kb");
            while ((length=input.read(_byte))!=-1) {
                System.out.print("文件名:"+file.getPath());
                System.out.print("\t文件大小:"+new DecimalFormat("0.00").format((double)file.length()/1024)+"kb");
                System.out.print("\t已解密大小:"+new DecimalFormat("0.00").format((double)(file.length()-input.available())/1024)+"kb");
                System.out.println("\t已解密比例:"+(sum==0?"100%":new DecimalFormat("0.00%").format((double)(sum-input.available())/sum)));
                output.write(_byte, 0, length);
            }
            System.out.println();
            input.close();
            output.close();
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}

更多推荐

Java绿盾解密- Ldterm(绿盾加密文件解密)

本文发布于:2023-06-14 04:40:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1439490.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:加密文件   Java   Ldterm

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!