home *** CD-ROM | disk | FTP | other *** search
/ Club Amiga de Montreal - CAM / CAM_CD_1.iso / files / 157.lha / Arc_Src / arccode.c < prev    next >
Encoding:
C/C++ Source or Header  |  1988-04-27  |  1.3 KB  |  37 lines

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