--- title: "Inverse Cryptology" id: 76469 type: "computer_media" slug: "inverse-cryptology" url: "http://localhost/computer_media/inverse-cryptology/" markdown_url: "http://localhost/computer_media/inverse-cryptology.md" published_at: "2026-11-11T08:02:40+00:00" modified_at: "2026-11-11T08:02:40+00:00" author: "David Anderson" featured_image: url: "http://localhost/wp-content/uploads/2026/11/inverse-cryptology-1.png" excerpt: "A two-player code-breaking game: one player enters a phrase, the computer enciphers it, and the other player guesses the letters one at a time." post_tag: - name: "Downloadable" slug: "downloadable" taxonomy: "post_tag" url: "http://localhost/tag/downloadable/" - name: "ZX80" slug: "zx80" taxonomy: "post_tag" url: "http://localhost/tag/zx80/" model: - name: "Sinclair ZX80" slug: "zx80" taxonomy: "model" url: "http://localhost/model/zx80/" indiv: - name: "Harold Lamkin" slug: "harold-lamkin" taxonomy: "indiv" url: "http://localhost/indiv/harold-lamkin/" genre: - name: "Game" slug: "game" taxonomy: "genre" url: "http://localhost/type/game/" media_type: "Program" programmers: - name: "Harold Lamkin" slug: "harold-lamkin" taxonomy: "indiv" url: "http://localhost/indiv/harold-lamkin/" download_url: "https://archive.org/download/timex-sinclair-software-archive/Inverse%20Cryptology%20%281981%29%28Lamkin%2C%20Harold%29%28ZX80%29%28US%29%28Program%29.zip" mediadate: "1981" images: - url: "http://localhost/wp-content/uploads/2026/11/inverse-cryptology-1.png" - url: "http://localhost/wp-content/uploads/2026/11/inverse-cryptology-2.png" - url: "http://localhost/wp-content/uploads/2026/11/inverse-cryptology-3.png" article_media: - id: 19739 title: "Inverse Cryptology" type: "article" url: "http://localhost/article/inverse-cryptology/" related_content: - id: 19711 title: "Dear Editor" type: "article" url: "http://localhost/article/dear-editor-22/" media_type_tags: "Game" license: false --- # Inverse Cryptology A code-breaking game for two players on a 1K ZX80. Player 1 types a phrase, and the program prints it in a random substitution cipher. Player 2 guesses with coded letter = real letter; a right guess replaces that letter everywhere with its inverse-video original. Typing the whole phrase solves it, and the program reports the number of wrong guesses. The cipher is never stored: the program re-encodes the phrase from a 26-element array each time it prints it, to save memory. Harold Lamkin sent a better way to exit the game to the July 1981 Dear Editor column. Published in Syntax June 1981 ([Inverse Cryptology](https://timexsinclair.com/article/inverse-cryptology/)). ## Source Code ``` 10 DIM A(25) 20 RANDOMISE 30 FOR Z=0 TO 25 40 LET A(Z)=RND(26)+37 60 FOR X=0 TO 25 70 IF A(Z)=A(X) AND NOT Z=X THEN GO TO 40 80 NEXT X 90 NEXT Z 100 PRINT "STATE A PHRASE" 110 INPUT W$ 120 GO SUB 600 400 PRINT 410 PRINT "ENTER PHRASE OR LETTER=LETTER" 420 INPUT U$ 425 IF U$=W$ THEN GO TO 900 430 IF NOT CODE(TL$(U$))=227 THEN GO TO 700 440 LET Y=CODE(TL$(TL$(U$))) 450 IF Y<38 OR Y>63 THEN GO TO 700 460 IF NOT A(Y-38)=CODE(U$) THEN GO TO 700 470 LET A(Y-38)=Y+128 480 CLS 485 PRINT "CORRECT" 490 GO SUB 600 491 IF Z=0 THEN GO TO 900 495 GO TO 400 600 PRINT 605 LET Z=0 610 LET U$=W$ 620 LET Y=CODE(U$) 630 IF Y<38 OR Y>63 THEN PRINT CHR$(Y); 640 IF Y<38 OR Y>63 THEN GO TO 650 645 PRINT CHR$(A(Y-38)); 646 IF NOT A(Y-38)=Y+128 THEN LET Z=Z+1 650 IF Y=1 THEN GO TO 680 660 LET U$=TL$(U$) 670 GO TO 620 680 PRINT 690 RETURN 700 LET X=X+1 705 CLS 710 PRINT "TRY AGAIN" 720 GO SUB 600 730 GO TO 400 900 CLS 910 PRINT "YOU BROKE THE CODE WITH ";X-26;" ERRORS ";W$ ```