[ create a new paste ] login | about

Project: programmingpraxis
Link: http://programmingpraxis.codepad.org/SUkyyUpu    [ raw code | fork ]

programmingpraxis - Scheme, pasted on Oct 27:
1
2
3
4
5
6
7
8
9
10
11
; 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))))))))))


Create a new paste based on this one


Comments: