/** * Basic encryption class using rotation. * * @version 1.0 * @author John Kloss */ public class Encrypt { /** * Modulus value which is set to the max value of an ASCII character * (one byte). */ final static int MOD_VALUE = 256; int rotateValue; // Amount to rotate forward a byte value /** * Creates a new Encrypt instance. * * @param value The value to which this Encrypt's * rotateValue is set. */ public Encrypt(int value) { rotateValue = value; } /** * Encrypts and returns a byte value. * * @param b The byte value to encrypt. * * @return The encrypted value of b */ public int encrypt(int b) { return (int) (b + rotateValue) % MOD_VALUE; } }