home *** CD-ROM | disk | FTP | other *** search
/ Technotools / Technotools (Chestnut CD-ROM)(1993).ISO / unix / arcunx11 / arc.sh1 / arccode.c < prev    next >
Encoding:
C/C++ Source or Header  |  1987-04-01  |  1.5 KB  |  49 lines

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