哪位大侠帮帮忙,帮我看看下面的加密方法,写个注册机?
test-2008@tom.com
谢谢!
void RegSystem()
{
char serial_no[20];
char hdstr[20],hdno[9];
char InStrReg[20];
char RegNum[20],str[20],str1[20],str2[20];
union REGS r;
struct SREGS s;
unsigned sno1, sno2;
FILE *fp;
int i;
struct date today,today1;
struct ffblk fblk;
getdate( &today1 );
r.x.ax = 0x6900;
r.h.bl = 3; /* A:=1, B:=2, C:=3 etc. */
segread(&s);
intdosx(&r, &r, &s);
if (r.x.cflag)
strcpy(serial_no , "");
else
{
sno2 = *((unsigned far *)MK_FP(s.ds, r.x.dx+2));
sno1 = *((unsigned far *)MK_FP(s.ds, r.x.dx+4));
getdate( &today );
today.da_year++;
today.da_mon+=10;
if ( today.da_mon > 12 )
{
today.da_mon -= 12;
today.da_year++;
}
sprintf( serial_no, "%04X%04X%04d%02d%02d0", sno1, sno2,today.da_year,today.da_mon,today.da_day );
for(i=0;i<17;i++)
{
serial_no[i]+=i;
}
serial_no[i]='\0';
sprintf( hdstr, "CAI%04XXU%04XCHU", sno1, sno2 );
sprintf( hdno, "%04X%04X", sno1, sno2 );
for( i=0;i<16;i++ )
hdstr[i] += i+today1.da_mon+today1.da_day;
hdstr[i]='\0';
}
// printf("The Serial Number of Login Disk [C] is %s", serial_no );
if (findfirst("cccxxx.dat",&fblk,0))
{
fp = fopen( "aaa.dat","r" );
fgets( RegNum,2,fp );
fclose( fp );
RegNum[1]='\0';
i = atoi( RegNum );
i++;
if ( i > 5 )
{
printf("\n Last Regis error!! Please Tel Or Fax." );
exit( 0 );
}
itoa( i, RegNum,10 );
fp = fopen( "aaa.dat","w" );
fputs( RegNum, fp );
fclose( fp );
printf("\nRegistNum %s", hdstr );
printf("\nPlease Input new RegistNum:" );
gets( InStrReg );
if ( strcmp( InStrReg, serial_no ))
{
printf( "\nRegister error!" );
exit(0);
}
else
{
fp = fopen( "cccxxx.dat","w" );
fputs( serial_no,fp );
fclose( fp );
}
}
else
{
fp = fopen("cccxxx.dat","r");
if ( fp == NULL )
exit( 0 );
fgets(str,18,fp);
fclose(fp);
str[17]='\0';
for(i=0;i<17;i++)
{
str[i] -= i;
}
for(i=0;i<8;i++)
str1[i]=str[i];
str1[8]='\0';
if ( strcmp( str1, hdno ) )
{
printf("\nserial_no1 error!" );
exit( 0 );
}
if ( str[16] != '0' )
exit( 0 );
else
{
for( i=8;i<16;i++ )
{
str1[i-8] = str[i];
}
str1[i-8]='\0';
getdate( &today );
sprintf( str2,"%04d%02d%02d",today.da_year,today.da_mon,today.da_day );
if ( atol(str2) > atol(str1) )
{
str[16]='1';
for (i=0;i<17;i++)
{
str1[i]=str[i]+i;
}
str1[i]='\0';
fp=fopen( "cccxxx.dat","w");
if (fp==NULL)
{
exit(0);
}
fputs(str1,fp);
fclose(fp);
exit( 0 );
[培训]内核驱动高级班,冲击BAT一流互联网大厂工作,每周日13:00-18:00直播授课