home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / snip9707.zip / CHKREG.C < prev    next >
C/C++ Source or Header  |  1997-07-05  |  2KB  |  53 lines

  1. /* +++Date last modified: 05-Jul-1997 */
  2.  
  3. /*************************************************************************
  4.  
  5.     CHKREG.C - Validates a key created by REGIT.C
  6.  
  7.    Donated to the Public Domain by Craig Morrison 12 May 1994, use,
  8.    abuse, fold, spindle or mutilate anyway you see fit.
  9.  
  10. *************************************************************************/
  11.  
  12. #include "regkey.h"
  13.  
  14. /*************************************************************************
  15.  
  16.     CHKREG accepts two arguments on its command line; The key value in
  17.     hexadecimal generated by REGIT and a string. You should end up with
  18.     XOR_PRIME after the XOR manipulations, if not, then the given key
  19.     was invalid.
  20.  
  21. *************************************************************************/
  22.  
  23. int main(int argc, char *argv[])
  24. {
  25.       long keyval;
  26.       long key;
  27.       char *p;
  28.       char buf[128];
  29.  
  30.       if (argc>2)
  31.       {
  32.             strcpy(buf, argv[1]);
  33.             strupr(buf);
  34.             sscanf(buf, "%8lX", &keyval);
  35.             keyval ^= XOR_POST_CRYPT;
  36.  
  37.             strcpy(buf, argv[2]);
  38.             p = strrev(buf);
  39.             while(*p)
  40.             {
  41.                   if (*p=='_')
  42.                         *p = ' ';
  43.  
  44.                   key = (long) toupper(*p);
  45.                   key ^= (long)XOR_CRYPT;
  46.                   keyval ^= key;
  47.                   p++;
  48.             }
  49.             printf("Key value = %08lX hex.\n", keyval);
  50.       }
  51.       return 0;
  52. }
  53.