/* * To change this template, choose Tools | Templates * and open the template in the editor. */ package ee.tlu.htk.dippler.utils; import java.security.NoSuchAlgorithmException; import java.security.SecureRandom; import java.util.UUID; /** * * @author metz */ public class GenerateId { public static String generateUID() { return UUID.randomUUID().toString(); } public static String getUID(String prefix) { return prefix+getUID(); } public static String getUID() { try { //Initialize SecureRandom //This is a lengthy operation, to be done only upon //initialization of the application SecureRandom prng = SecureRandom.getInstance("SHA1PRNG"); //generate a random number String randomNum = new Integer(prng.nextInt()).toString(); return GenerateHash.generateSHA1(randomNum); } catch (NoSuchAlgorithmException ex) { System.err.println(ex); } return null; } }