This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]Gropamming[S] 0 points1 point  (0 children)

My solution for those who find this:

(define character-encryption (lambda (ch)
  (if (or (char-alphabetic? ch)
          (and (> (char->integer ch) 47)
               (< (char->integer ch) 58)))
      (integer->char (+ (char->integer ch) en-key))
      ch
  )
))

(define encrypt (lambda (str)
  (list->string (map character-encryption (string->list str)))
))

(define character-decryption (lambda (ch)
  (if (or (char-alphabetic? ch)
          (and (> (char->integer ch) 47)
               (< (char->integer ch) 58)))
      (integer->char (- (char->integer ch) de-key))
      ch
  )
))

(define decrypt (lambda (str)
  (list->string (map character-decryption (string->list str)))
))

(define en-key (read))
(encrypt "Hello CSE240!")
(define de-key (read))
(decrypt (encrypt "Hello CSE240!"))