java数字密码字典生成器

直接上代码,如有不足请指出

import java.io.*;

/**
 * 描述:
 *java代码实现的字典生成器,新手写的,有不足之处可以指出
 *写个main()调用即可,create方法的参数为文件存储的路径
 * @author LCY
 * @create 2018-10-29 17:57
 */

public class CreateDictionary {
	//该方法的参数为保存文件的路径,例:String path = "H:\\测试用\\字典"
    public void create(String path){
        FileOutputStream fos = null;
        BufferedOutputStream bos = null;
        PrintWriter pw = null;
        try {
        	System.out.println("开始执行");
            fos = new FileOutputStream( path +"\\数字密码字典.txt");
            bos = new BufferedOutputStream( fos );
            pw = new PrintWriter( bos );
            System.out.println("获取io流成功,字典正在生成中...");
            int maxInt = 99999999;//最大范围,默认范围0-99999999
            int count = 8;//生成密码的位数,默认8位,例:00000001
            for(int i = 0;i<=maxInt;i++){
                String tempInt = i+"";
                int tempIntLength = tempInt.length();
                if(tempIntLength!=count){
                    StringBuilder sb = new StringBuilder( tempInt  );
                    for (int j = count-tempIntLength; j>=1;j--){
                        sb.insert( 0,0 );
                    }
                    pw.println( sb.toString() );
                }else{
                    pw.println( i );
                }
            }
            System.out.println( "字典创建完成" );
        } catch (FileNotFoundException e) {
        	System.out.println("路径填写有误");
            e.printStackTrace();
        }finally {
            pw.close();
            try {
                bos.close();
                fos.close();
                System.out.println("io流已关闭");
            } catch (IOException e) {
            	System.out.println("io流关闭出现异常");
                e.printStackTrace();
            }
        }
    }
}

  • 1
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
Python密码字典生成器可以通过Python编写一个脚本来实现。以下是一个简单的示例: ```python import itertools import argparse def generate_passwords(template_file, keywords, special_chars, output_file): # 读取模板文件 with open(template_file, 'r') as f: template = f.read().strip() # 生成关键字排列组合 keyword_combinations = [] for i in range(1, len(keywords) + 1): keyword_combinations += itertools.permutations(keywords, i) # 生成密码 passwords = [] for combination in keyword_combinations: password = template for keyword in combination: password = password.replace('{}', keyword, 1) passwords.append(password) # 添加特殊字符 if special_chars: passwords_with_special_chars = [] for password in passwords: for char_combination in itertools.product(special_chars, repeat=len(password)): password_with_special_chars = '' for i in range(len(password)): password_with_special_chars += password[i] + char_combination[i] passwords_with_special_chars.append(password_with_special_chars) passwords = passwords_with_special_chars # 写入文件 with open(output_file, 'w') as f: for password in passwords: f.write(password + '\n') if __name__ == '__main__': parser = argparse.ArgumentParser(description='Generate customized password dictionary.') parser.add_argument('-t', '--template', required=True, help='Template file path.') parser.add_argument('-k', '--keywords', required=True, help='Keywords separated by comma.') parser.add_argument('-s', '--special-chars', help='Special characters separated by comma.') parser.add_argument('-o', '--output', required=True, help='Output file path.') args = parser.parse_args() keywords = args.keywords.split(',') special_chars = args.special_chars.split(',') if args.special_chars else None generate_passwords(args.template, keywords, special_chars, args.output) ``` 使用方法: 1. 创建一个模板文件,例如`template.txt`,其中包含一个或多个`{}`占位符,用于替换关键字。 2. 运行以下命令生成密码字典: ``` python password_generator.py -t template.txt -k keyword1,keyword2,keyword3 -s !,@,#,$ -o passwords.txt ``` 其中,`-t`指定模板文件路径,`-k`指定关键字序列,以逗号分隔开,`-s`指定一些特殊符号,以逗号分隔开,`-o`指定输出后的文件名。 如果不需要特殊字符,可以省略`-s`参数。 生成的密码字典将保存在`passwords.txt`文件中。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

北漂的菜小白

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值