home *** CD-ROM | disk | FTP | other *** search
/ ftp.cs.arizona.edu / ftp.cs.arizona.edu.tar / ftp.cs.arizona.edu / icon / historic / v941.tgz / icon.v941src.tar / icon.v941src / ipl / progs / crypt.icn < prev    next >
Text File  |  2000-07-29  |  1KB  |  60 lines

  1. ############################################################################
  2. #
  3. #    File:     crypt.icn
  4. #
  5. #    Subject:  Program to encrypt file
  6. #
  7. #    Authors:  Phil Bewig and Phillip Lee Thomas
  8. #
  9. #    Date:     August 14, 1996
  10. #
  11. ############################################################################
  12. #
  13. #   This file is in the public domain.
  14. #
  15. ############################################################################
  16. #
  17. #  Do *not* use this in the face of competent cryptanalysis.
  18. #
  19. #  Usage: [iconx] icrypt [key] < infile > outfile
  20. #
  21. ############################################################################
  22. #
  23. #  As written, uses UNIX-style console I/O.
  24. #
  25. ############################################################################
  26.  
  27. procedure main(args)
  28.    local i, k, ky, l, con
  29.    local fin, fout, infile, outfile
  30.  
  31.    if *args = 3 then  {
  32.       ky      := get(args)
  33.       infile  := get(args)
  34.       outfile := get(args)
  35.       }
  36.  
  37.    else  {
  38.       writes("Enter password:    ")
  39.       # Note - password is visible
  40.       ky := read()
  41.       writes("Enter input file:  ")
  42.       infile := read()
  43.       writes("Enter output file: ")
  44.       outfile := read()
  45.       }
  46.  
  47.    fin  := open(infile, "ur")
  48.    fout := open(outfile,"uw")
  49.  
  50.    i := 1
  51.    l := 0
  52.    k := []
  53.    every put(k, ord(!ky)) do
  54.       l +:= 1
  55.  
  56.    while writes(fout, char(ixor(ord(reads(fin)), k[i])))  do  {
  57.       i := (i % l) + 1
  58.       }
  59. end
  60.