The not so young any more, but still very promising cryptographer Børge is implementing a new security module for his company. There were a lot of problems with the old module last time Børge was on holiday, as nobody could understand his code. So his boss have ordered him to keep this new module much simpler.
In this system the secret encryption key is an injective function c from the alphabet onto itself, such that for a string S = s1 . . . sm, we have crypt(S) = c(s1). . . c(sm). The secret decryption key c−1has the property c−1(c(s)) = s, and is used in the decryption crypt−1(T) = c−1(t1). . . c−1(tm). Børge’s functions crypt() and crypt−1() send each symbol with a Remote Procedure Call to where the secret keys are stored, deep inside a mountain.
A problem is that cryptq(crypt(S)) = S for some q, and the eager cracker can just keep on applying crypt() on the encrypted message until he gets a readable message. To make the system totally safe, Børge wants to make crypt() throw a
SecurityExceptionInAmundsCodeReally if q is a small number. Help Børge implement this function.