Java examples for java.util:Random
Gets the random number.
//package com.java2s; import java.math.BigInteger; import java.security.MessageDigest; import java.security.NoSuchAlgorithmException; public class Main { /**/* w ww.j a v a 2 s . c o m*/ * Gets the random number. * * @param s the s * @return the random number * @throws Exception the exception */ public static int getRandomNumber(String s) throws Exception { MessageDigest m; try { m = MessageDigest.getInstance("MD5"); byte[] data = s.getBytes(); m.update(data, 0, data.length); BigInteger i = new BigInteger(1, m.digest()); return i.intValue(); } catch (NoSuchAlgorithmException e) { } throw new Exception("Cannot generate random number"); } }