This sophisticated coder and decoder runs in only 2K. Use it for fun as a stand-alone program, or create a subroutine to make your datafiles unintelligible without the keyword. Of course, keywords must exist somewhere, here it’s Y$, and the program clears it after each run. When you make a data-protection subroutine, reset Y$.
Take the keyword out when you SAVE the program–set Y$ to some new value–and remember the exact keyword or you can’t crack the code. Trying to decode after you reset Y$ produces garbage.

Both the keyword and message may be of any length, but you can’t use any of the graphics characters. You may use A-Z, spaces, 0-9, and any of .,:;$<>()+-=?* in either key or message.
5 FAST
10 PRINT "CIPHER/DECIPHER? C/D";
15 INPUT Q$
16 PRINT Q$
18 PRINT
20 PRINT "KEYWORD:";
30 INPUT Y$
40 PRINT "CENSORED"
42 PRINT
45 DIM Z(LEN Y$)
50 FOR Z=1 TO LEN Y$
60 LET Z(Z)=CODE Y$(Z)-13
70 IF Z(Z)<0 THEN LET Z(Z)=51
110 NEXT Z
200 PRINT "ENTER MESSAGE:"
210 INPUT M$
220 PRINT M$
230 PRINT
260 IF Q$(1)="D" THEN GOTO 400
300 PRINT "CIPHER -->"
305 LET Y=1
310 FOR Z=1 TO LEN M$
315 IF Y>LEN Y$ THEN LET Y=1
320 LET T=CODE M$(Z)
325 LET X=Z(Y)+T+9
328 IF T=0 THEN LET X=X+64
330 LET X=X-51*INT (X/51)+13
332 IF X=63 THEN LET X=-1
334 PRINT CHR$ (X+1);
335 LET Y=Y+1
340 NEXT Z
350 GOTO 500
400 PRINT "DECODED -->"
410 LET Y=1
420 FOR Z=1 TO LEN M$
430 IF Y>LEN Y$ THEN LET Y=1
435 LET T=CODE M$(Z)
440 LET X=T-Z(Y)-24
445 IF T=0 THEN LET X=X+64
450 IF X>=13 THEN GOTO 460
454 LET X=X+51
456 GOTO 450
460 IF X=63 THEN LET X=-1
465 PRINT CHR$ (X+1);
470 LET Y=Y+1
480 NEXT Z
500 CLEAR
SYNTACTIC SUM: 51442, 8K ROM

Note: Type-in program listings on this website use ZMAKEBAS notation for graphics characters.