自动生成用户名,密码的方法

1.随机取6位数的数字,做为密码

      public String getpassword(){
  
              Random r = new Random();
              int x = r.nextInt(999999);
              String a = String.valueOf(x);
              return a;
      }

2.取8位数做为用户名,前两位为AD,后几位为从数据库中取出的ID,不足8位时中间补0

      public String getLoginName(String seqcode){
               //seqcode是传过来的流水号
               int id = Integer.parseInt(seqcode);
               String LoginName="AD"+(""+(id+1000000)).substring(1);
               return LoginName;
      }

3.从数据库中取出密码,用*把密码替换掉

      //oldPassword是从库中取出的密码,"."表示任意字符

         String newPassword = oldPassword.replaceAll(".","*");

原文地址:https://www.cnblogs.com/wifi/p/2192800.html