After you get the value for temp, you need to check it to see if it has exceeded the boundaries you've set... if so, then you need to decide what to do... does the value wrap back around so that it goes ...XYZabcd... or do you simply truncate the value at the specified ceiling (which may present a problem at decryption time)... or something else...

-tg