home *** CD-ROM | disk | FTP | other *** search
/ NOVA - For the NeXT Workstation / NOVA - For the NeXT Workstation.iso / Apps / ArchiveUtils / nx_arc / arccode.c < prev    next >
Encoding:
C/C++ Source or Header  |  1992-12-20  |  1.3 KB  |  49 lines

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