summaryrefslogtreecommitdiff
path: root/ipl/progs/crypt.icn
blob: 086a5f19a20b9c4ca6a5069d5fee337dbe37090a (plain)
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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
############################################################################
#
#	File:     crypt.icn
#
#	Subject:  Program to encrypt file
#
#	Authors:  Phil Bewig and Phillip Lee Thomas
#
#	Date:     August 14, 1996
#
############################################################################
#
#   This file is in the public domain.
#
############################################################################
#
#  Do *not* use this in the face of competent cryptanalysis.
#
#  Usage: [iconx] icrypt [key] < infile > outfile
#
############################################################################
#
#  As written, uses UNIX-style console I/O.
#
############################################################################

procedure main(args)
   local i, k, ky, l, con
   local fin, fout, infile, outfile

   if *args = 3 then  {
      ky      := get(args)
      infile  := get(args)
      outfile := get(args)
      }

   else  {
      writes("Enter password:    ")
      # Note - password is visible
      ky := read()
      writes("Enter input file:  ")
      infile := read()
      writes("Enter output file: ")
      outfile := read()
      }

   fin  := open(infile, "ur")
   fout := open(outfile,"uw")

   i := 1
   l := 0
   k := []
   every put(k, ord(!ky)) do
      l +:= 1

   while writes(fout, char(ixor(ord(reads(fin)), k[i])))  do  {
      i := (i % l) + 1
      }
end