100 REM 110 REM ************* FILE ENCRYPTION PROGRAM ************* 120 REM 130 REM USES VERNAM'S ALGORITHM WITH THREE KEYWORDS 140 REM 150 REM ALAN SCLAWY, JULY, 1980 160 REM 170 REM *************************************************** 180 REM 190 REM VARIABLES: 200 REM 210 REM F$ FILE NAME 220 REM K1$,K2$,K3$ KEYWORDS 230 REM K1, K2, K3 POINTERS TO CHARACTERS IN KEYWORDS 240 REM L1, L2, L3 LENGTHS OF KEYWORDS 250 REM IN$ TEXT LINE CURRENTLY BEING ENCRYPTED 260 REM EN LENGTH OF IN$ 270 REM Z$ CHARACTER FROM IN$ CURRENTLY BEING 280 REM ENCIPHERED 290 REM P HOLDS NUMERICAL EQUIVALENT OF Z$ 300 REM Y$ ENCRYPTED VERSION OF Z$ 310 REM OT$ ENCRYPTED VERSION OF IN$ 320 REM 330 REM *************************************************** 340 REM 350 REM ------- MAKE ROOM FOR STRINGS 360 CLEAR 400 370 REM 380 REM ------- GET FILE NAMES & OPEN FILES 390 INPUT "Input file"; F$ 400 OPEN "I", 1, F$ 410 INPUT "Output file"; F$ 420 OPEN "O", 2, F$ 430 REM 440 REM ------- GET KEYWORDS 450 INPUT "Key"; K1$ 460 K1 = 1 470 L1 = LEN(K1$) 480 INPUT "Key"; K2$ 490 K2 = 1 500 L2 = LEN(K2$) 510 INPUT "Key"; K3$ 520 K3 = 1 530 L3 = LEN(K3$) 540 REM 550 REM --------- LOOP ON RECORDS ------------------------- 560 FOR I = 1 TO 32767 570 IF (EOF(1) ) THEN 920 580 LINE INPUT #1, IN$ 590 EN = LEN(IN$) 600 REM PRINT "EN = "; EN 610 REM PRINT IN$ 620 OT$ = "" 630 REM 640 REM --------- LOOP ON CHARACTRES WITHIN RECORD -------- 645 IF (EN=0) THEN 880 650 FOR J = 1 TO EN 660 Z$ = MID$(IN$, J, 1) 670 U$ = MID$(K1$, K1, 1) 680 P = ASC(Z$) XOR ASC(U$) 690 K1 = K1 + 1 700 IF (K1 > L1) THEN K1 = 1 710 V$ = MID$ (K2$, K2, 1) 720 P = P XOR ASC(V$) 730 K2 = K2 + 1 740 IF (K2 > L2) THEN K2 = 1 750 W$ = MID$(K3$, K3, 1) 760 P = P XOR ASC(W$) 770 K3 = K3 + 1 780 IF (K3 > L3) THEN K3 = 1 790 Y$ = CHR$ (P) 800 REM --- PREVENT INADVERTENT NULL, CR, LF, OR EOF 810 IF P <> 0 AND P <> 10 AND P <> 13 AND P <> 26 THEN 830 820 Y$ = Z$ 830 OT$ = OT$ + Y$ 840 REM PRINT J; ASC(Z$), U$; V$; W$; ASC(Y$) 850 NEXT J 860 REM --------- END OF LOOP ON CHARACTERS 870 REM ------- WRITE OUTPUT RECORD 880 PRINT #2, OT$ 900 NEXT I 910 REM --------- END OF LOOP ON RECORDS 920 CLOSE 1, 2 930 END