A device of applying protection bit codes to encrypt a program for
protection is disclosed. The program has a plurality of instructions P
(positive integer). The device includes a protection-bit-code generator,
a first protection-bit-code location generator and a protection-bit-code
insertion unit. The protection-bit-code generator generates a plurality
of protection bit codes in accordance with the plurality of instructions
of the program, wherein each instruction has a plurality of bits I
(positive integer). The first protection-bit-code location generator
generates a plurality of insertion positions N (positive integer) for
each protection bit code in accordance with processor status when
executing the program. The protection-bit-code insertion unit inserts
each protection bit code in a position between (N-1)th- and Nth-bit of a
respective instruction of the program in accordance with the insertion
position N generated by the first protection-bit-code location generator,
thereby generating an encrypted program.