300字范文,内容丰富有趣,生活中的好帮手!
300字范文 > Java绿盾解密- Ldterm(绿盾加密文件解密)

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

时间:2019-12-04 19:42:34

相关推荐

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

废话不多说,直接上代码

直接运行 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();}}}

本内容不代表本网观点和政治立场,如有侵犯你的权益请联系我们处理。
网友评论
网友评论仅供其表达个人看法,并不表明网站立场。