Creating an easter egg and hiding it from other developers

If you want to create an easter egg and make sure other developer’s that have access to the source code don’t know what’s going on, you can use the encryption and message digests functions that are available in the standard JDK.

First of all, you need a key that only you know. The key could be the sequence of steps one has to go through to see the egg. For example, clicking on the right mouse button on a component then typing giraffesarecool. So the first step is to manually compute a messagedigest from those events by capturing and concatenating them together.
Eg.

   KEY = MessageDigest(MouseEvt(right click) + KeyEvent('g') + KeyEvent('i') + ... )

KEY could be “3F4D1054FFA30B”.
Now program your class in such a way that it captures the events and compares it with the messagedigest that you have hardcoded:

   newEvent(Event e) {
      totalEvents += e;
      if (MessageDigest(totalEvents) == "3F4D1054FFA30B") {
         // invoke easter egg
      }
   }

The easter egg could be in a separate class that you have encrypted. The key for encryption should be different than the key to invoke the easter egg. If you don’t, another fellow developer could decrypt the class with the hardcoded key and see the easter egg with some minor code modifications. You can create the decryption (and encryption) key by taking a concatenation on for instance the inverse of the events:

   newEvents(Event e) {
      totalEvents += e;
      if (MessageDigest(totalEvents) == "3F4D1054FFA30B") {
         INVERSE = totalEvents.inverse();
         decrypt class (eg. stored as a JPG resource) with key INVERSE
         load class
         invoke easter egg on class
      }
   }

Another developer can only notice that something in your code is obscure but cannot figure out what the result of it is. He doesn’t know how to invoke it neither what it does.