68. Secure cipher code ~~~~~~~~~~~~~~~~~~ One of the most fascinating stories of World War II concerns how British Intelligence were able to crack the codes generated by the German "Enigma" cipher machines. Thanks to a simple but elegant idea from James Slater, you too can produce very secure code using your Beeb. The method relies on the fact that you can "seed" the random number generator to start at different points in the pseudo-random sequence, and the message can't be decoded unless you know the "key" integer number used to seed the generator in the first place. The ASCII code is shifted by a random amount each time, and if you type a continuous string of A's, you will see the result! Note that the random number generator on the Master/Compact is coded differently from that on a BBC B/B+, so there is no compatibility between them when using this technique. The more digits you use in your key number, the harder it will be to crack the code by chance. The message may contain any keyboard character, including , but not . I am sure this cipher would not be considered secure in the context of giant business computers, which can try umpteen millions of combinations in a short time, but I reckon it could be a useful way of protecting private data on micros. If you make the alterations shown underneath, only capitals will be allowed, and the test is forced into 5-letter groups for extra security. Try it, it's great fun, but NOT over the air - it's strictly against the rules! 100 MODE6:INPUT''"Enter CODE KEY... "n% 110 randomize=RND(-(ABS(n%))) 120 PRINT'"Decipher or Encipher (D/E) ? "; 130 REPEATg$=CHR$(GETAND&DF):c%=INSTR("DE",g$)*2-3:UNTILc%<>-3 140 PRINTg$''"Please type your MESSAGE"' 150 REPEAT:REPEATg%=GET:UNTILg%>31ANDg%<127 160 IFPOS>38THENPRINT'' 170 k%=g%-32+c%*(RND(95)-1):VDUg%,10,8(k%+95)MOD95+32,11 180 UNTILFALSE Alternative lines for 5-letter groups, capitals only: 150 REPEAT:REPEATg%=GET:UNTILg%>64ANDg%<91 160 IFPOS>35THENPRINT'''" ";ELSEIFPOS MOD6=0 THEN PRINT" "; 170 k%=g%-65+c%*(RND(25)-1):VDUg%,10,8(k%+25)MOD25+65,11