reptkey.scm 772 B

123456789101112131415161718192021222324252627
  1. ;;;
  2. ;;; Repeating key encipher and decipher
  3. ;;;
  4. ;;; Copyright 2016 Jason K. MacDuffie
  5. ;;; License: GPLv3+
  6. ;;;
  7. (define (reptkey-xcipher pt-in key-in direction)
  8. ;; A repeating key cipher, commonly known as "Vigenere"
  9. ;; I reject that name because it has little to do with
  10. ;; Vigenere at all. Anyway, this just involves taking
  11. ;; a key and repeating it until the end of the plain
  12. ;; text, then applying tabula recta.
  13. ;;
  14. ;; Encipherment and decipherment are similar, so I
  15. ;; am sharing the code body for both.
  16. (define l (apply circular-list key-in))
  17. (direction pt-in l))
  18. (define (reptkey-encipher pt-in key-in)
  19. (reptkey-xcipher pt-in key-in runkey-encipher))
  20. (define (reptkey-decipher pt-in key-in)
  21. (reptkey-xcipher pt-in key-in runkey-decipher))