import java.util.Random; public class TrickCipherDemo { public static void main(String[] args) { int max = 1000000000; Numbers n; if (args.length > 0) n = new RandomNumbers(max, args[0].hashCode()); else n = new SequentialNumbers(); TrickCipher tc = new TrickCipher(max, "this is a key".getBytes()); for (int i = 0; i < 20; ++i) { int x = n.next(); System.out.print(x); int c = tc.encrypt(x); System.out.print("\t"); System.out.print(c); int p = tc.decrypt(c); System.out.print("\t"); System.out.println(p); } } } interface Numbers { public int next(); } class SequentialNumbers implements Numbers { private int i; public int next() { return i++; } } class RandomNumbers implements Numbers { Random rnd; private int max; public RandomNumbers(int max, long seed) { this.max = max; rnd = new Random(); } public int next() { return rnd.nextInt(max); } }