成功捷徑,貴在堅持
          人為善,福雖未至禍已遠離; 人為惡,禍雖未至福已遠離

          import java.util.Random;

          /**
          ?*? <p>@Description:</p>
          ?*? <p>@Company:???? 上海###########公司</p>
          ?*? <p>@CreateDate:? 2006-4-19</p>
          ?*???? @author:????? zyk
          ?*??? @version:???? 1.0?
          ?*/

          public class GenerateRandomPassword {
          ?
          ?//密碼生成字符
          ?public static String PASSWORDCHAR[]=new String[]{"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",
          ??"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"
          ?};
          ?
          ?//生成密碼的位數
          ?public static int LENGTH=6;
          ?
          ?/**
          ? * @Function:<p> 生成密碼隨機數</p>
          ? * @param str? 獲取生成密碼的字符
          ? * @param len? 控制生成密碼的位數
          ? * @return
          ? * @author zyk
          ? * @CREATEDATE 2006-4-19?
          ? */
          ?public static String getRandom(String str[],int len){
          ??String temp="";
          ??int rand;
          ??Random random = new Random();
          ??//random.setSeed(str.length);
          ??for(int i=0;i<len;i++){
          ???rand=random.nextInt(str.length);??????
          ???temp+=str[rand];
          ??}
          ??return temp;
          ?}
          }

          posted on 2006-05-09 17:35 選寶網an9 閱讀(392) 評論(1)  編輯  收藏 所屬分類: java

          FeedBack:
          # re: 產生隨機密碼
          2007-10-23 17:34 | gembin
          good  回復  更多評論
            

          只有注冊用戶登錄后才能發表評論。


          網站導航:
           
          主站蜘蛛池模板: 集贤县| 安泽县| 仁寿县| 蒲江县| 牙克石市| 鄂伦春自治旗| 调兵山市| 海林市| 澎湖县| 忻城县| 旌德县| 孝感市| 康乐县| 墨玉县| 赞皇县| 巢湖市| 南澳县| 镇远县| 北流市| 恭城| 迭部县| 施甸县| 西昌市| 苍山县| 磐石市| 新营市| 三河市| 资源县| 泌阳县| 吉林省| 衡阳市| 阿合奇县| 普格县| 四川省| 仙游县| 亚东县| 鹤山市| 顺义区| 宁国市| 汤阴县| 宾川县|