############################################################################ # # 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