note

JAVA 임시 비밀번호 생성 본문

JSP/기본

JAVA 임시 비밀번호 생성

투한 2012. 5. 7. 13:33


	public static String shufflePasswd(int len) {

		if(len == 0) len = 10;
		
		char[] charSet = new char[]{
				'0','1','2','3','4','5','6','7','8','9'
				,'A','B','C','D','E','F','G','H','I','J','K','L','M'
				,'N','O','P','Q','R','S','T','U','V','W','X','Y','Z'};

		int idx = 0;
		StringBuffer sb = new StringBuffer();
		for(int i=0; i<len; i++){
			idx = (int)(charSet.length*Math.random());
			sb.append(charSet[idx]);
		}
		
		//아이디값을 받아서 db update
		
		return sb.toString().toLowerCase();
	}

	public static void main(String[] args){
		System.out.println("임시비밀번호생성 Start");
		System.out.println(">>>>" + shufflePasswd(10) );
		System.out.println("임시비밀번호생성 End");
	}