home *** CD-ROM | disk | FTP | other *** search
/ Programmer 7500 / MAX_PROGRAMMERS.iso / PROGRAMS / UTILS / COMPRESS / ARC520S.ZIP / ARCCODE.C < prev    next >
Encoding:
C/C++ Source or Header  |  1986-10-23  |  1.4 KB  |  40 lines

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