home *** CD-ROM | disk | FTP | other *** search
/ Usenet 1994 January / usenetsourcesnewsgroupsinfomagicjanuary1994.iso / sources / misc / volume1 / 8707 / 64 / arccode.c < prev    next >
Encoding:
C/C++ Source or Header  |  1990-07-13  |  1.8 KB  |  59 lines

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