生成动态长度的随机密码

package com.book.util;

import org.apache.commons.lang.RandomStringUtils;

/**
 * @see RandomPwd随机生成密码
 * @version 1.0
 *
 */
public class RandomPwd
{
	public static String random() 
	{
        String str = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijkmnpqrstuvwxyz";//初始化种子
        return RandomStringUtils.random(9, str);//返回9为的字符串
    }
	public static void main(String[] args)
	{
		System.out.println(random());
	}
}

你可能感兴趣的:(java,apache)