package cn.com.lzt.tools; import java.util.Random; /** * * ClassName: SaltUtil * * @Description: 加盐处理 * @author zhijia.wang * @date 2017-6-9下午2:20:36 */ public class SaltUtil { private static String[] WORDS = new String[] { "a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "m", "n", "p", "q", "r", "s", "t", "u", "v", "w", "x", "y", "z", "A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "M", "N", "P", "Q", "R", "S", "T", "U", "V", "W", "X", "Y", "Z", "0", "1", "2", "3", "4", "5", "6", "7", "8", "9" }; public static String randomSalt(int size) { StringBuffer sb = new StringBuffer(); Random random = new Random(); for (int i = 0; i < size; i++) { sb.append(WORDS[random.nextInt(WORDS.length)]); } return sb.toString(); } public static int randon6Num() { return new Random().nextInt(899999) + 100000; } public static int randon5Num() { return new Random().nextInt(89999) + 10000; } public static int randon4Num() { return new Random().nextInt(8999) + 1000; } public static int randon3Num() { return new Random().nextInt(899) + 100; } }