/**/
/*++
Copyright (c) 2007 YourCompany
Module Name:
<new>
Abstract:
密码生成器:密码产生输出到文件
对产生的密码排序,输出到文件(未实现)
对四个1000 000 的文件合并(未实现)
Author:
YourName (YourEmail) 2007-06-08
Revision History:
--*/
#include < stdio.h >
#include < stdlib.h >
#include < string .h >
#include < assert.h >
#define NUM 30 // 密码串的产生个数
#define CIPHER_LEN 20 // 一个密码串的最大长度
/**/ /*++
Description: Produ_cipher()
Function :密码产生函数
Arguments :char filename[]-->输入文件名
Return Value:none
--*/
void Produ_cipher( const char * filename)
... {
int i,j;
int seed;
FILE *fp;
char a[CIPHER_LEN+1];
//memset(a,0,CIPHER_LEN); //??数组建立的时候自动初始化为0不用初始??
if((fp=fopen(filename,"w"))==NULL)
...{
printf("can not open the file");
exit(0);
}
for(j=NUM;j>0;j--)
...{
for(i=0;i<CIPHER_LEN;i++) //密码长度为CIPHER_LEN
...{
seed=rand()%3;
// if(seed>3) abort();
switch(seed)
...{
case 0: a[i]=(char)( rand()%26+'a');break;
case 1: a[i]=(char)( rand()%26+'A');break;
case 2: a[i]=(char)( rand()%10+'0');break;
default : printf("this is error ");
}
}
a[CIPHER_LEN]='/0';
printf("%s/n",a);
fwrite(a,CIPHER_LEN,1,fp);
//printf("the cipher%s written into file successfully /n",a);
}
printf("the cipher written into file successfully /n");
fclose(fp);
//printf("--------------------------------------------/n");
//In_file(a[MS]);
}
Copyright (c) 2007 YourCompany
Module Name:
<new>
Abstract:
密码生成器:密码产生输出到文件
对产生的密码排序,输出到文件(未实现)
对四个1000 000 的文件合并(未实现)
Author:
YourName (YourEmail) 2007-06-08
Revision History:
--*/
#include < stdio.h >
#include < stdlib.h >
#include < string .h >
#include < assert.h >
#define NUM 30 // 密码串的产生个数
#define CIPHER_LEN 20 // 一个密码串的最大长度
/**/ /*++
Description: Produ_cipher()
Function :密码产生函数
Arguments :char filename[]-->输入文件名
Return Value:none
--*/
void Produ_cipher( const char * filename)
... {
int i,j;
int seed;
FILE *fp;
char a[CIPHER_LEN+1];
//memset(a,0,CIPHER_LEN); //??数组建立的时候自动初始化为0不用初始??
if((fp=fopen(filename,"w"))==NULL)
...{
printf("can not open the file");
exit(0);
}
for(j=NUM;j>0;j--)
...{
for(i=0;i<CIPHER_LEN;i++) //密码长度为CIPHER_LEN
...{
seed=rand()%3;
// if(seed>3) abort();
switch(seed)
...{
case 0: a[i]=(char)( rand()%26+'a');break;
case 1: a[i]=(char)( rand()%26+'A');break;
case 2: a[i]=(char)( rand()%10+'0');break;
default : printf("this is error ");
}
}
a[CIPHER_LEN]='/0';
printf("%s/n",a);
fwrite(a,CIPHER_LEN,1,fp);
//printf("the cipher%s written into file successfully /n",a);
}
printf("the cipher written into file successfully /n");
fclose(fp);
//printf("--------------------------------------------/n");
//In_file(a[MS]);
}
/*++
Description:main(int argc, char* argv[])
Function :主函数
Arguments:
默认文件名:mimatxt
Function :主函数
Arguments:
默认文件名:mimatxt
Return Value:none
--*/
--*/
int main(int argc, char* argv[]) //主函数部分
{
char *filename="mimatxt";
printf("--------------------------------------------/n");
printf("Function:Generate cipher : /n");
printf("Remark :Generate quility is NUM=30 /n");
printf("Remark :The length of cipher is CIPHER_LEN=20 /n");
printf("Remark :Ddfult file name is mimatxt /n");
printf("--------------------------------------------/n");
//filename={'m','i','m','a','t','x','t'};
//printf("please input the file name:/n");
//scanf("%s",filename);
Produ_cipher(filename);
return 0;
{
char *filename="mimatxt";
printf("--------------------------------------------/n");
printf("Function:Generate cipher : /n");
printf("Remark :Generate quility is NUM=30 /n");
printf("Remark :The length of cipher is CIPHER_LEN=20 /n");
printf("Remark :Ddfult file name is mimatxt /n");
printf("--------------------------------------------/n");
//filename={'m','i','m','a','t','x','t'};
//printf("please input the file name:/n");
//scanf("%s",filename);
Produ_cipher(filename);
return 0;
}
//问题:怎么在定义文件名的时候选择路径呢?
//对产生的密码排序??? 怎么个思路呢? 呵呵,要再想想
//对产生的密码排序??? 怎么个思路呢? 呵呵,要再想想