Java绿盾解密- Ldterm(绿盾加密文件解密)
生活随笔
收集整理的這篇文章主要介紹了
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();}} }總結
以上是生活随笔為你收集整理的Java绿盾解密- Ldterm(绿盾加密文件解密)的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: html form src,form.h
- 下一篇: JavaEE 启示录