C语言 破解字典生成器

#include <stdio.h>
#include <stdlib.h>  
#include<string.h>  
#define CHARLANG 96
FILE *fp; /*文件指针*/ 
char* join3(char *s1, char *s2)  
{  
    char *result = malloc(strlen(s1)+strlen(s2)+1);//+1 for the zero-terminator  
    //in real code you would check for errors in malloc here  
  
    strcpy(result, s1);  
    strcat(result, s2);  
  
    return result;  
}  


char *create(int num){
	char str[100];
	itoa(num, str, 10);
      char p[5] =".txt";
      
     return join3(str,p);
    
}
int full(int a,int *b){
	int i=0;
    int count=0;
    while(i<a){
		if(b[i]!=0){
			count++;
        }	
        i++;
    }
    if(count==0){
		return 1;
    }else {
		return 0;
    }
}


void add(int a,int *b){
	int i=0;
	b[0]++;
    while(i<a){
		if(b[i]>=CHARLANG){
			b[i]=0;
            b[i+1]++; 
        }
        i++;
    }
}
void out(int a,int *b, char *c){
int i=0;

	for(i=0;i<a;i++){
			fprintf(fp,"%c",c[b[i]]);
            printf("%c",c[b[i]]);
        }
        fprintf(fp,"\n");
        printf("\n");
}
int main()

{  char a[CHARLANG]="0123456789abcdefghjijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ[]~.',/\\:!?@#$%^&*()<>_+|~`{ }-;\""; 
	int b[20]={0};
 
    
int i=0;	
int j=0;//字典长度
int k=5000;//字典分割长度
int l=0;
    int num=1;
   
     printf("请输入字典长度");
     scanf("%d",&j);
       fp = fopen("1.txt","w");
   while(1){
      out(j,b,a);
      add(j,b);
		if(full(j,b)==1){

			fclose(fp); /*关闭文件*/ 
			break;
        }
        l++;
	   if(l%k==k-1){
			fclose(fp); /*关闭文件*/
            num++; 
            fp = fopen(create(num),"w");
       }
       
        
        
     }
    fclose(fp); /*关闭文件*/ 
			printf("生成成功");
	system("pause");

	return 0;
}

评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值