A system and method for securing code segments and ensuring proper
execution using state-based encryption is presented. A class loader
captures a memory state snapshot and uses the memory state snapshot for
generating a key that encrypts a class. The class loader subsequently
captures additional memory state snapshots at specific execution cycle
times, and uses the memory state snapshots to generate additional keys
that encrypt subsequent code segments. The encrypted code segments are
stored in a file that is distributed to client computers. The client
computer decrypts the individual code segments using keys that are
generated from client memory state snapshots. If a particular code
segment is not loaded in order or has been altered, the code segment is
not decrypted properly and the software program terminates.