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(".","*");

 posted on 2011-09-27 09:53  纳米程序员  阅读(3503)  评论(0编辑  收藏  举报