TIGHT SECURITY for Sinclair ZX-81
by Andrew ho
from Your Computer, January 1983

Ideas for maintaining program confidentiality have been published before in
Basic, requiring the user to input a secret codeword before the program
will run. Such security checks are easily bypassed in Basic by the use of
Break or Stop keys. This code routine cannot be circumvented. The machine
code is stored in a Rem statement containing 50 characters, as the first
line of the program.

The routine starting at 16516 prints a screen prompt, then calls the
key-scan subroutine in ROM many thousand timess, seeking for a secret
combination of keys to be pressed. If this is not found within 27 seconds,
it jumps to the New subroutine in ROM and erases the program, thus
preventing unauthorised access. To be effective, this idea should be
incorporated in a program which auto-runs on loading from cassette.

The line following the program line containing Save should enter the
machine code routine at 16516 immediately, as illustrated in the sample
program. The routine will work in both 1K and 16K machines, although it
will probably find more use in 16K programs which might store confidential
information. The screen is cleared and the counter reset before entry to
the main program, so that further copies of the program will still feature
this security check.

The secret codeword may be two, three or any number of any keys to be
simultaneously pressed, thus making it impossible for uninformed users to
breach the security check.

Your own secret codeword can be used if you understand how the key-scan
routine operates in ROM. For those who do not, here are some possibilities:

16535  16536  codeword
9D     D9     AHO
7D     F1     ASM
7B     F3     WM
AE     E6     Shift X 7J