1 34 package net.myvietnam.mvncore.security; 35 36 import org.apache.commons.lang.RandomStringUtils; 37 38 public class RandomGenerator { 39 40 private RandomGenerator() { 42 } 43 44 public static String getRandomMD5_Base64() { 45 String randomString = getRandomString(); 46 return Encoder.getMD5_Base64(randomString); 47 } 48 49 private static String getRandomString() { 50 StringBuffer randomString = new StringBuffer (128); 52 randomString.append(String.valueOf(System.currentTimeMillis())); 53 randomString.append(RandomStringUtils.randomAlphanumeric(30)); 54 randomString.append(RandomStringUtils.randomNumeric(30)); 55 randomString.append(String.valueOf(System.currentTimeMillis())); 56 return randomString.toString(); 57 } 58 59 public static void main (String args[]) { 60 System.out.println("getRandomString = " + getRandomString()); 61 System.out.println("getRandomMD5_Base64 = " + getRandomMD5_Base64()); 62 } 63 } 64 | Popular Tags |