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

  1. /* +++Date last modified: 05-Jul-1997 */
  2.  
  3. /*************************************************************************
  4.  
  5.    REGIT.C - A very simple registration key generator. Uses simple XOR
  6.    manipulations of a string to create a key.
  7.  
  8.    It is NOT foolproof, but it will work.
  9.  
  10.    Donated to the Public Domain by Craig Morrison 12 May 1994, use,
  11.    abuse, fold, spindle or mutilate anyway you see fit.
  12.  
  13. *************************************************************************/
  14.  
  15. #include "regkey.h"
  16.  
  17. /*************************************************************************
  18.  
  19.     REGIT accepts one argument on the command line; The string you want
  20.     to use to generate a key from. It outputs the generated key in both
  21.     decimal and hexadecimal form. Spaces in the argument should have the
  22.     '_' character used in their place, they get translated below.
  23.  
  24. *************************************************************************/
  25.  
  26. int main(int argc, char *argv[])
  27. {
  28.       long keyval = (long)XOR_PRIME;
  29.       long key;
  30.       char *p;
  31.       char buf[128];
  32.  
  33.       if (argc>1)
  34.       {
  35.             strcpy(buf, argv[1]);
  36.             p = buf;
  37.             while(*p)
  38.             {
  39.                   if (*p=='_')
  40.                         *p = ' ';
  41.  
  42.                   key = (long) toupper(*p);
  43.                   key ^= (long)XOR_CRYPT;
  44.                   keyval ^= key;
  45.                   p++;
  46.             }
  47.             keyval ^= (long)XOR_POST_CRYPT;
  48.             printf("Key value = %08lX hex, %lu decimal.\n", keyval, keyval);
  49.       }
  50.       return 0;
  51. }
  52.