TECH NOTES / 开发工具
解密亿赛通加密的项目
原笔记 2022-07-08 · 整理于 2026-10-05
保留加密环境下文件复制实验的代码,说明其依赖授权环境和文件备份的前提。
实验说明:下面的程序本身只做目录遍历和文件复制,并不实现密码学解密。其表现依赖原加密客户端及获准读取文件的环境,不能保证适用于其他机器或版本。只在有权处理的文件副本上验证,不要覆盖唯一原件。
Maven依赖
<dependency>
<groupId>commons-io</groupId>
<artifactId>commons-io</artifactId>
<version>2.5</version>
</dependency>解密亿赛通加密的项目
public class Test {
public static void main(String[] args) throws IOException {
// 要解密的项目路径
final String projectPath = "D:\\IdeaProjects\\test-project";
// 重命名文件
final String newProjectPath = batchRename(projectPath);
// 解密
decryptFiles(newProjectPath);
}
public static void decryptFiles(String newProjectPath) throws IOException {
Collection<File> filteredFiles = FileUtils.listFiles(new File(newProjectPath), TrueFileFilter.INSTANCE, FileFilterUtils.directoryFileFilter());
String decryptProjectPath = newProjectPath.substring(0, newProjectPath.length() - 1) + "-decrypt";
for (File file : filteredFiles) {
final String oldAbsolutePath = file.getAbsolutePath();
// 替换地址
final String replace = oldAbsolutePath.replace(newProjectPath, decryptProjectPath);
// 去除文件结尾的“1”
final String newAbsolutePath = replace.substring(0, replace.length() - 1);
FileUtils.copyFile(new File(oldAbsolutePath), new File(newAbsolutePath));
System.out.println("解密文件:" + newAbsolutePath);
}
System.out.println("解密项目成功,项目地址:" + decryptProjectPath);
}
public static String batchRename(String projectPath) throws IOException {
// 过滤器
IOFileFilter filter1 = FileFilterUtils.notFileFilter(FileFilterUtils.nameFileFilter("target"));
IOFileFilter filter2 = FileFilterUtils.notFileFilter(FileFilterUtils.nameFileFilter(".git"));
IOFileFilter filter3 = FileFilterUtils.notFileFilter(FileFilterUtils.nameFileFilter(".idea"));
IOFileFilter filter = FileFilterUtils.and(filter1, filter2, filter3);
// 目录下所有文件
Collection<File> filteredFiles = FileUtils.listFiles(new File(projectPath), TrueFileFilter.INSTANCE, filter);
final String newProjectPath = projectPath + "1";
for (File file : filteredFiles) {
final String oldAbsolutePath = file.getAbsolutePath();
final String newAbsolutePath = oldAbsolutePath.replace(projectPath, newProjectPath) + "1";
FileUtils.copyFile(new File(oldAbsolutePath), new File(newAbsolutePath));
System.out.println("新文件:" + newAbsolutePath);
}
System.out.println("重命名项目成功,项目地址:" + newProjectPath);
return newProjectPath;
}
}