'Copyright 2002 The American Cryptogram Association (ACA) '3613 Piedmont Drive, Plano TX 75075-6234 'All rights reserved. 'Calculate LR stat 'by BION, bmason@cell2000.net CLS DEFINT A-Z PRINT "LR calculator by BION" INPUT "Name of ciphertext file"; Fil$ Cipher$ = "" OPEN Fil$ FOR INPUT AS #1 WHILE NOT EOF(1) INPUT #1, C$ IF INSTR(C$, " ") > 0 THEN PRINT C$ PRINT "Remove spaces from ";Fil$ CLOSE #1 END END IF Cipher$ = Cipher$ + C$ WEND CLOSE #1 PRINT "Cipher text is:" PRINT Cipher$ DIM nReps(20) 'Number of repeats L = LEN(Cipher$) PRINT "Cipher text length is "; L PRINT "Calculating..." FOR i = 1 TO L - 3 FOR j = i + 1 TO L N = 0 StrI$=MID$(Cipher$, i + N , 1) StrJ$=MID$(Cipher$, j + N , 1) WHILE j+N <= L AND StrI$ = StrJ$ N = N + 1 StrI$=MID$(Cipher$, i + N , 1) StrJ$=MID$(Cipher$, j + N , 1) WEND IF N > 1 THEN IF N > 10 THEN N = 10 nReps(N) = nReps(N) + 1 END IF NEXT j NEXT i PRINT "There were:" Hdr$ = " repeats of length " FOR i = 2 TO 9 PRINT nReps(i); Hdr$ ; i NEXT i PRINT nReps(10); Hdr$; "10 or more" PRINT PRINT "LR stat for "; Fil$; " is"; PRINT 1000 * SQR(nReps(3)) / L PRINT PRINT "Averages: Plain 22, "; PRINT "Fmorse 16, Vigenere 9, "; PRINT "Bifid 7, Random 4"