public static synchronized String generateKey ( ) { String code = "" ; long nr = System . currentTimeMillis ( ) ; if ( nr <= lastnr ) { nr = lastnr + 1 ; } lastnr = nr ; String s = String . valueOf ( nr ) ; for ( int i = 0 ; i < s . length ( ) ; i ++ ) { code += codeArray [ randomizer . nextInt ( 6 ) ] [ s . charAt ( i ) - 48 ] ; } return code ; }
Generates a random key which is guaranteed to be unique within the application .