Android 自界说肴杂字典

打印 上一主题 下一主题

主题 1051|帖子 1051|积分 3153

添加下面的代码,用新的肴杂字典,随机大小写字母组合
  1. package com.jiuhong.mbtirgtest.util;
  2. import java.io.FileWriter;
  3. import java.io.IOException;
  4. import java.util.HashSet;
  5. import java.util.Random;
  6. import java.util.Set;
  7. public class ObfuscationDictionaryGeneratorUtil {
  8.     public static void generateObfuscationDictionary(String filePath, int count) {
  9.         Set<String> uniqueWords = new HashSet<>();  // 使用 Set 确保唯一性
  10.         while (uniqueWords.size() < count) {
  11.             uniqueWords.add(generateRandomWord(3, 10));
  12.         }
  13.         try (FileWriter writer = new FileWriter(filePath)) {
  14.             for (String word : uniqueWords) {
  15.                 writer.write(word + "\n");
  16.             }
  17.             System.out.println("混淆字典已生成: " + filePath);
  18.         } catch (IOException e) {
  19.             System.err.println("生成混淆字典失败: " + e.getMessage());
  20.         }
  21.     }
  22.     private static String generateRandomWord(int minLength, int maxLength) {
  23.         Random random = new Random();
  24.         int wordLength = random.nextInt(maxLength - minLength + 1) + minLength;
  25.         StringBuilder word = new StringBuilder(wordLength);
  26.         for (int i = 0; i < wordLength; i++) {
  27.             char randomChar = (char) (random.nextBoolean() ? 'A' + random.nextInt(26) : 'a' + random.nextInt(26));
  28.             word.append(randomChar);
  29.         }
  30.         return word.toString();
  31.     }
  32. }
复制代码
生成字典文件
  1.         // 调用方法生成混淆字典
  2.         String filePath = this.getFilesDir().getAbsolutePath() + "/obfuscation_dictionary.txt";
  3.         
  4.         int count = 10000; // 生成 10000 条记录
  5.         ObfuscationDictionaryGeneratorUtil.generateObfuscationDictionary(filePath, count);
复制代码
在Device Explorer找到这个文件
  1. /data/user/0/com.j.mt/files/obfuscation_dictionary.txt
复制代码
拖到APP目次下

在肴杂文件中添加规则

  1. #用于字段名和方法名混淆。
  2. -obfuscationdictionary obfuscation_dictionary.txt
  3. #用于类名混淆。
  4. -classobfuscationdictionary obfuscation_dictionary.txt
  5. #用于包名混淆。
  6. -packageobfuscationdictionary obfuscation_dictionary.txt
复制代码
免责声明:如果侵犯了您的权益,请联系站长,我们会及时删除侵权内容,谢谢合作!更多信息从访问主页:qidao123.com:ToB企服之家,中国第一个企服评测及商务社交产业平台。

本帖子中包含更多资源

您需要 登录 才可以下载或查看,没有账号?立即注册

x
回复

使用道具 举报

0 个回复

倒序浏览

快速回复

您需要登录后才可以回帖 登录 or 立即注册

本版积分规则

傲渊山岳

论坛元老
这个人很懒什么都没写!
快速回复 返回顶部 返回列表