home *** CD-ROM | disk | FTP | other *** search
/ Frozen Fish 1: Amiga / FrozenFish-Apr94.iso / bbs / alib / d0xx / d050 / unixarc.lha / UnixArc / arccode.c < prev    next >
Encoding:
C/C++ Source or Header  |  1987-01-17  |  1.3 KB  |  38 lines

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