1. A method of executing program code located in a memory having a plurality of memory slots, the program code having an encrypted function in a first memory slot, the method comprising: decrypting, by a processor, the encrypted function using a first cipher module located in a second memory slot to obtain a decrypted function; executing, by the processor, the decrypted function; re-encrypting, by the processor, the decrypted function using a second cipher module located in a third memory slot to obtain a re-encrypted function; storing, by the processor, the re-encrypted function in a fourth memory slot, different from the first memory slot; and moving, by the processor, the second cipher module from the third memory slot to a fifth memory slot after the re-encryption step, the fifth memory slot being different than the third memory slot.