File: arccode.c

package info (click to toggle)
arc 5.21q-15
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 636 kB
  • sloc: ansic: 6,630; makefile: 323
file content (45 lines) | stat: -rw-r--r-- 1,139 bytes parent folder | download | duplicates (6)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
/*
 * ARC - Archive utility - ARCCODE
 * 
 * Version 1.02, created on 01/20/86 at 13:33:35
 * 
 * (C) COPYRIGHT 1985-87 by System Enhancement Associates.
 * You may copy and distribute this program freely,
 * under the terms of the General Public License.
 * 
 * By:	Thom Henderson
 * 
 * Description: This file contains the routines used to encrypt and decrypt data
 * in an archive.  The encryption method is nothing fancy, being just a
 * routine XOR, but it is used on the packed data, and uses a variable length
 * key.	 The end result is something that is in theory crackable, but I'd
 * hate to try it.  It should be more than sufficient for casual use.
 * 
 * Language: Computer Innovations Optimizing C86
 */
#include <stdio.h>
#include "arc.h"

static char    *p;		/* password pointer */

VOID
setcode()
{				/* get set for encoding/decoding */
	p = password;		/* reset password pointer */
}

VOID
codebuf(buf, len)		/* encrypt a buffer */
	reg char       *buf;
	u_int		len;
{
	reg u_int	i;
	reg char       *pasptr = p;

	for (i = 0; i < len; i++) {
		if (!*pasptr)
			pasptr = password;
		*buf++ ^= *pasptr++;
	}
	p = pasptr;
}