java.util.Random产生的随机数是有一定周期的,改进了lcg的一个版本..还是security安全点. 
import java.util.Random; /**  * <p>Title: </p>  * <p>Description: </p>  * <p>Copyright: Copyright (c) 2001</p>  * <p>Company: </p>  * @author not attributable  * @version 1.0  */ 
 public class RandomCracker { protected static final long a=0x5deece66dL; protected static final long b=0xbL; protected static final long m=(1L<<48)-1; 
 public static void crack(int xint0,int xint1)   { long i; long seed=-1L; long x0=(xint0&0xFFFFFFFFL)<<16; long x1=(xint1&0xFFFFFFFFL); for(i=0;i<0xFFFFL;i++){     seed=(((x0+i)*a)+b)&m;     if ((seed>>>16)==x1){ 
    break;     } seed=-1L; } if (seed==-1L)   {   throw new RuntimeException("Input Error!");} else{ 
System.out.println("The Cracked x2="+(int)(((seed*a)+b&m)>>>16)); } 
} public static void main(String args[]) { Random r=new Random(); int x0=r.nextInt(); int x1=r.nextInt(); System.out.println("            x0= "+x0); System.out.println("            x1= "+x1); crack(x0,x1); System.out.println("   The Real x2="+r.nextInt()); 
} } 
   
 
  |