Here is the code of the functions that I have:

(setq list ' ((((Ш К Э Ы О) (( )) (Ы)) ((Ш Ы Ж ((( ))) Т Ы) (З М Т Э ( ) К) (Щ Й У O)) (( )) ((Д У З И Э) ( ((( ))) Ш С Э П П) (Ш) ( ) ) ((Г Щ Щ У Т) ( ) )) (((Ъ З С П ( ) Ь) (Ь)) ((Л Р (( )) П )) ((С Щ Ь Х ( ) Р) (Ч Е Ш П Д) ( ) ) ((Ы И О Ф Е) ((( ))) (Ы К)) ((Ш М) ( ) ) ((Ф Ш С Э Ъ) ( ) (Ф Э К))) ((( ((( ))) Х Л Ш О А) (Й) (( )) ) ((М Р О А Ш) ( ) (П Д))))) (defun badp (Z) (cond ((null Z) T) ((atom Z) nil) ((and (null (cdr Z)) (listp (car Z))) (badp (car Z))) ((atom (car Z)) nil) (t nil) )) (defun clear (Y) (cond ((null Y) nil) ((badp (car Y)) (clear (cdr Y))) ((listp (car Y)) (cons (clear (car Y)) (clear (cdr Y)))) (t (cons (car Y) (clear (cdr Y)))) )) (clear list) (defun OneList (X) (cond ((null X) nil) ((listp (car X)) (append (oneList (car X)) (OneList (cdr X)))) (T (cons (car X) (OneList (cdr X)))) )) (onelist list) (defun alfavit (d) (let ((result nil)) (loop for l from 0 to 31 do (setq result (cons (list-to-delimited-string (list (+ l (- d 1)) - (int-char (+ 192 l))) " ") result)) ) (list-to-delimited-string (reverse result) ", ") )) (alfavit 1) (defun preGamm (text key ngamma) (LET* ( (spisok (coerce text 'list)) (keyspisok (coerce text 'list)) (j 0) (n (- (length keyspisok) 1)) (result nil)) (for i from 0 to (- (length spisok) 1) do (if (= ngamma 1) (PROGN (setq result (cons (nth j keyspisok) result)) (if (< jn) (setq j (+ j 1)) (setq j 0)) ) (if (OR (equal (nth i spisok) #\space) (equal (nth i spisok) #\.)) (setq result (cons (nth i spisok) result)) (PROGN (setq result (cons (nth j keyspisok) result)) (if (< jn) (setq j (+ j 1)) (setq j 0)) )) )) (list-to-delimited-string (reverse result) ""))) (defun Vigener-MG (text key ngamma) (LET ( (source (coerce text 'list)) (keygamma (coerce (pregamm text key ngamma) 'list)) (kriptogramma nil)) (for i from 0 to (- (length source) 1) do (if (OR (equal (nth i source) #\space) (equal (nth i source) #\.)) (setq kriptogramma (cons (nth i source) kriptogramma)) (setq kriptogramma (cons (int-char (+ 192 (mod (- (+ 32 (- (char-int (nth i source)) 192)) (- (char-int (nth i keygamma)) 192)) 32))) kriptogramma))) ) (list-to-delimited-string (reverse kriptogramma) ""))) 

Functions Vigener-MG and preGamm from the manual, there is also a function of the frequency of the appearance of letters in the cryptogram and that's it. As I understood, Vigener-MG and preGamm are for encrypting the text, but I need to decipher the cryptogram, that is, vice versa. Task: Cipher Vizhener-mg, the key "MIRROR", the number of gamming is 1 (without a gap to the space and the end of the sentence, that is, the key MIRROR to repeat also where there are dots and spaces), Predicate error: if the sublist without elements is I am made by the Clear function, which removes these "bulbs". OneList function said to write to remove all internal brackets

Lisp is for the first time in our country, so I don’t understand how to remake Vigener-MG and preGamm to decrypt my cryptogram

  • I do not want to understand this wall of code. It is not clear to me what the algorithm is. Maybe you can figure it out yourself, and when a more specific problem arises, ask a question? - Vladimir Gordeev
  • The fact of the matter is that I can not figure it out. - gvenog
  • here is the reference for Common Lisp functions, and here is an accessible textbook in Russian on Common Lisp. Understand. - Vladimir Gordeev
  • I don’t know, probably in Common Lisp (a program on it?) The upper and lowcase are not important (that is, T and T or OneList and oneList) are the same thing. In Emacs, this is not the case. I tried your code and came across it. Correct laziness! Do you have something that does not go? - avp 1:01 pm
  • everything goes, it's just algorithms for encryption, and why should I encrypt the cryptogram again? i need the inverse algorithm vigener-MG wednesday: ALLEGRO - gvenog

1 answer 1

  1. Read the description of the Vigenere algorithm - http://ru.m.wikipedia.org/wiki/%D0%A8%D0%B8%D1%84%D1%80_%D0%92%D0B8%D0%B6%D0% B5% D0% BD% D0% B5% D1% 80% D0% B0
  2. You do not need to do anything with the existing functions. You need to write your own for rasshirovki.
  3. It is obvious that the encryption algorithm is not always equivalent to the decryption algorithm. Sometimes their complexity may differ by orders of magnitude, and the transformations may not be obvious. Therefore, read the full description of the algorithm and implement it in the form of code.
  • Here I try to understand and the question arose. here is my cryptogram without "garbage": (((((C K E E O) (S)) ((S C F T S)) (S M E E C) (S Y O S Sh)) ((D O S I E) (W S E P P) (W)) ((G SCH U U T))) (((b C S P b) (b)) ((L P P)) ((S Sch b x P ) (CH E P F)) ((S and O F E) (S K)) ((W M)) ((F W C e b) (F E C))) (((CH L N O A) (C)) ((M OO A W) (P D)))) where 2 brackets inside are opened, this is a word, where three brackets are a sentence. How can I remove these brackets and put a space between words, and between sentences a period with a space? Words for example: S K E O S O S Y S S S T E C S M E S S E C S Y O S S - this is an ultrasound - sensitive sensor - gvenog
  • already figured out, the question is removed - gvenog
  • Explain how you dragged the '-' symbol in the 'sensor-ultrasound' out of this cryptogram ??? - avp