www.pudn.com > encryption.rar > X9_17KeyGen.java
/*
Christoforos Pirillos @ Villanova University - May 1999
based on code from the book "Java Network Programming" by Hughes
*/
package encryption;
/**Produces random 64-bit values according to ANSI X9.17 specification,
that uses the DES encryption algorithm*/
public class X9_17KeyGen {
protected DES des;
protected long v;
/**We start the generator by providing a key and a seed*/
public X9_17KeyGen (long key, long seed) {
des = new DES(key);
v=seed;
}
/**Returns a 64-bit key*/
public long nextKey() {
long t=des.encrypt(System.currentTimeMillis() );
long r=des.encrypt(t^v);
v=des.encrypt(t^r);
return r;
}
}