home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 9 Archive / 09-Archive.zip / OS2ARC_S.ZIP / ARCCODE.C < prev    next >
C/C++ Source or Header  |  1987-10-14  |  2KB  |  46 lines

  1. /*  ARC - Archive utility - ARCCODE
  2.  
  3. $define(tag,$$segment(@1,$$index(@1,=)+1))#
  4. $define(version,Version $tag(
  5. TED_VERSION DB =1.02), created on $tag(
  6. TED_DATE DB =01/20/86) at $tag(
  7. TED_TIME DB =13:33:35))#
  8. $undefine(tag)#
  9.     $version
  10.  
  11. (C) COPYRIGHT 1985 by System Enhancement Associates; ALL RIGHTS RESERVED
  12.  
  13.     By:  Thom Henderson
  14.  
  15.     Description:
  16.          This file contains the routines used to encrypt and decrypt
  17.          data in an archive.  The encryption method is nothing fancy,
  18.          being just a routine XOR, but it is used on the packed data,
  19.          and uses a variable length key.  The end result is something
  20.          that is in theory crackable, but I'd hate to try it.  It should
  21.          be more than sufficient for casual use.
  22.  
  23.     Language:
  24.          Computer Innovations Optimizing C86
  25. */
  26. #include <stdio.h>
  27. #include "arc.h"
  28.  
  29. static char *p;                        /* password pointer */
  30.  
  31. setcode()                              /* get set for encoding/decoding */
  32. {
  33.     p = password;                      /* reset password pointer */
  34. }
  35.  
  36. int code(c)                            /* encode some character */
  37. int c;                                 /* character to encode */
  38. {
  39.     if(p)                              /* if password is in use */
  40.     {    if(!*p)                       /* if we reached the end */
  41.               p = password;            /* then wrap back to the start */
  42.          return c^*p++;                /* very simple here */
  43.     }
  44.     else return c;                     /* else no encryption */
  45. }
  46.