; crypt

(define (crypt key infile outfile)
  (define (last-pair xs) (if (null? (cdr xs)) xs (last-pair (cdr xs))))
  (define (cycle xs) (set-cdr! (last-pair xs) xs) xs)
  (with-input-from-file infile (lambda ()
    (with-output-to-file outfile (lambda ()
      (do ((key (cycle (map char->integer (string->list key))) (cdr key))
           (char (read-char) (read-char)))
          ((eof-object? char))
        (display (integer->char (logxor (car key) (char->integer char))))))))))
