package com.oo.liu.demo01;

import java.nio.charset.MalformedInputException;

public class createPassword {
	/**
	 * 此类是随机生成8位数字、英文(大小写)、特殊符号的密码
	 */
	public static void number() {
		/**
		 * 计算字符串
		 */
		int n=0;
		String reference="QWERTYUIOPASDFGHJKLZXCVBNM1234567890qwertyuiopasdfghjklzxcvbnm!@#$%^&*()";
	
		char[] strarr=reference.toCharArray();//字符串转换成字符
		for (int i = 0; i < strarr.length; i++) {
			n++;
		}
		System.out.println("字符串个数:"+n);
		
	}
	public static void passRandom() {
		String pass=null;
		String textString="";
		String reference="QWERTYUIOPASDFGHJKLZXCVBNM1234567890qwertyuiopasdfghjklzxcvbnm!@#$%^&*()";
		StringBuffer buffer=new StringBuffer(reference);
		System.out.println(buffer.charAt(23));
		for (int i = 0; i < 8; i++) {
            //随机产生0-72的数字
			int ran=(int)(Math.random()*72);
            //buffer.charAt()是索引该位置的字符
			textString+=buffer.charAt(ran);
		}
		System.out.println(textString);
	}
	public static void main(String[] args) {
		
		passRandom();
	}
}

相关文章:

  • 2021-10-23
  • 2021-08-07
  • 2021-11-28
  • 2022-02-09
  • 2022-12-23
猜你喜欢
  • 2021-11-16
  • 2022-12-23
  • 2022-02-14
  • 2022-01-22
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案