亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關于我們
? 蟲蟲下載站

?? randomstrg.java

?? Jive論壇2.5版本的源程序
?? JAVA
字號:
package com.jivesoftware.util;

/**
 * <p>Title: </p>
 * <p>Description: </p>
 * <p>Copyright: Copyright (c) 2002</p>
 * <p>Company: </p>
 * @author unascribed
 * @version 1.0
 */

import java.util.*;
import java.security.SecureRandom;
import java.security.NoSuchAlgorithmException;
import java.security.NoSuchProviderException;

/**
 * tool of random string creator, for password or session id
 *     RandomStrg rstr=new RandomStrg();
 *     rstr.setCharset("a-zA-Z0-9");
 *          rstr.setLength(32);
 *          rstr.generateRandomObject();
 *           String randstr=rstr.getRandom();
 * @author Sunny Peng
 */
public class RandomStrg {

    private Integer length = new Integer(8);
    public void setLength(int count){ length =new Integer(count);}

    private String randomstr;
    private boolean allchars = false;

    private HashMap hmap;
    private ArrayList lower = null;
    private ArrayList upper = null;
    private char[] single = null;
    private int singlecount = 0;
    private boolean singles = false;
    private String algorithm = null;
    private String provider = null;
    private boolean secure = false;
    private Random random = null;
    private SecureRandom secrandom = null;

    private final float getFloat() {
        if (random == null)
            return secrandom.nextFloat();
        else
            return random.nextFloat();
    }

    /**
     * generate the Random object that will be used for this random number
     * generator
     *
     */
    public final void generateRandomObject() throws Exception {

        // check to see if the object is a SecureRandom object
        if (secure) {
            try {
                // get an instance of a SecureRandom object
                if (provider != null)
                    // search for algorithm in package provider
                    random = SecureRandom.getInstance(algorithm, provider);
                else
                    random = SecureRandom.getInstance(algorithm);
            } catch (NoSuchAlgorithmException ne) {
                throw new Exception(ne.getMessage());
            } catch (NoSuchProviderException pe) {
                throw new Exception(pe.getMessage());
            }
        } else
            random = new Random();
    }

    /**
     * generate the random string
     *
     */
    private final void generaterandom() {

        if (allchars)
            for (int i = 0; i < length.intValue(); i++)
                randomstr = randomstr + new Character((char)((int) 34 +
                                     ((int)(getFloat() * 93)))).toString();
        else if (singles) {
            // check if there are single chars to be included

            if (upper.size() == 3) {
                // check for the number of ranges max 3 uppercase lowercase digits

                // build the random string
                for (int i = 0; i < length.intValue(); i++) {
                    // you have four groups to choose a random number from, to make
                    // the choice a little more random select a number out of 100

                    // get a random number even or odd
                    if (((int) (getFloat() * 100)) % 2 == 0) {

                        // the number was even get another number even or odd
                        if (((int) (getFloat() * 100)) % 2 == 0)
                            // choose a random char from the single char group
                            randomstr = randomstr + randomSingle().toString();
                        else
                            // get a random char from the first range
                            randomstr = randomstr + randomChar((Character)lower.get(2),
                                                (Character)upper.get(2)).toString();
                    } else {
                        // the number was odd

                        if (((int) (getFloat() * 100)) % 2 == 0)
                            // choose a random char from the second range
                            randomstr = randomstr + randomChar((Character)lower.get(1),
                                               (Character)upper.get(1)).toString();
                        else
                            // choose a random char from the third range
                            randomstr = randomstr + randomChar((Character)lower.get(0),
                                               (Character)upper.get(0)).toString();
                    }
                }
            } else if (upper.size() == 2) {
                // single chars are to be included choose a random char from
                // two different ranges

                // build the random char from single chars and two ranges
                for (int i = 0; i < length.intValue(); i++) {
                    // select the single chars or a range to get each random char
                    // from

                    if (((int)(getFloat() * 100)) % 2 == 0) {

                        // get random char from the single chars
                        randomstr = randomstr + randomSingle().toString();
                    } else if (((int) (getFloat() * 100)) % 2 == 0) {

                        // get the random char from the first range
                        randomstr = randomstr + randomChar((Character)lower.get(1),
                                               (Character)upper.get(1)).toString();
                    } else {

                        // get the random char from the second range
                        randomstr = randomstr + randomChar((Character)lower.get(0),
                                               (Character)upper.get(0)).toString();
                    }
                }
            } else if (upper.size() == 1) {

                // build the random string from single chars and one range
                for (int i = 0; i < length.intValue(); i++) {
                    if (((int) getFloat() * 100) % 2 == 0)
                        // get a random single char
                        randomstr = randomstr + randomSingle().toString();
                    else
                        // get a random char from the range
                        randomstr = randomstr + randomChar((Character)lower.get(0),
                                               (Character)upper.get(0)).toString();
                }
            } else {
                // build the rand string from single chars
                for (int i = 0; i < length.intValue(); i++)
                    randomstr = randomstr + randomSingle().toString();
            }
        } else {

            // no single chars are to be included in the random string
            if (upper.size() == 3) {

                // build random strng from three ranges
                for (int i = 0; i < length.intValue(); i++) {

                    if (((int) (getFloat() * 100)) % 2 == 0) {

                        // get random char from first range
                        randomstr = randomstr + randomChar((Character)lower.get(2),
                                               (Character)upper.get(2)).toString();
                    } else if (((int) (getFloat() * 100)) % 2 == 0) {

                        // get random char form second range
                        randomstr = randomstr + randomChar((Character)lower.get(1),
                                               (Character)upper.get(1)).toString();
                    } else {

                        // get random char from third range
                        randomstr = randomstr + randomChar((Character)lower.get(0),
                                               (Character)upper.get(0)).toString();
                    }
                }
            } else if (upper.size() == 2) {

                // build random string from two ranges
                for (int i = 0; i < length.intValue(); i++) {
                    if (((int) (getFloat() * 100)) % 2 == 0)
                        // get random char from first range
                        randomstr = randomstr + randomChar((Character)lower.get(1),
                                               (Character)upper.get(1)).toString();
                    else
                        // get random char from second range
                        randomstr = randomstr + randomChar((Character)lower.get(0),
                                             (Character)upper.get(0)).toString();
                }
            } else

                // build random string
                for (int i = 0; i < length.intValue(); i++)
                    // get random char from only range
                    randomstr = randomstr + randomChar((Character)lower.get(0),
                                               (Character)upper.get(0)).toString();
        }
    }

    /**
     * generate a random char from the single char list
     *
     * @returns - a randomly selscted character from the single char list
     *
     */
    private final Character randomSingle() {

        return (new Character(single[(int)((getFloat() * singlecount) - 1)]));
    }

    /**
     * generate a random character
     *
     * @param lower  lower bound from which to get a random char
     * @param upper  upper bound from which to get a random char
     *
     * @returns - a randomly generated character
     *
     */
    private final Character randomChar(Character lower, Character upper) {
        int tempval;
        char low = lower.charValue();
        char up = upper.charValue();

        // get a random number in the range lowlow - lowup
        tempval = (int)((int)low + (getFloat() * ((int)(up - low))));

        // return the random char
        return (new Character((char) tempval));
    }

    /**
     * get the randomly created string for use with the
     * &lt;jsp:getProperty name=<i>"id"</i> property="randomstr"/&gt;
     *
     * @return - randomly created string
     *
     */
    public final String getRandom() {

        randomstr = new String();

        generaterandom(); // generate the first random string

        if (hmap != null) {

            while (hmap.containsKey(randomstr)) {
                // random string has already been created generate a different one
                generaterandom();
            }

            hmap.put(randomstr, null);  // add the new random string
        }

        return randomstr;
    }

    /**
     * set the ranges from which to choose the characters for the random string
     *
     * @param low  set of lower ranges
     * @param up  set of upper ranges
     *
     */
    public final void setRanges(ArrayList low, ArrayList up) {
        lower = low;
        upper = up;
    }


    /**
     * set the hashmap that is used to check the uniqueness of random strings
     *
     * @param map  hashmap whose keys are used to insure uniqueness of random strgs
     *
     */
    public final void setHmap(HashMap map) {
        hmap = map;
    }

    /**
     * set the length of the random string
     *
     * @param value  length of the random string
     *
     */
    public final void setLength(String value) {
            length = new Integer(value);

    }

    /**
     * set the algorithm name
     *
     * @param value  name of the algorithm to use for a SecureRandom object
     *
     */
    public final void setAlgorithm(String value) {
        algorithm = value;
        secure = true;  // a SecureRandom object is to be used
    }

    /**
     * set the provider name
     *
     * @param value  name of the package to check for the algorithm
     *
     */
    public final void setProvider(String value) {
        provider = value;
    }

    /**
     * set the allchars flag
     *
     * @param value  boolean value of the allchars flag
     *
     */
    public final void setAllchars(boolean value) {
        allchars = value;
    }

    /**
     * set the array of single chars to choose from for this random string and the
     * number of chars in the array
     *
     * @param chars  the array of single chars
     * @param value  the number of single chars
     *
     */
    public final void setSingle(char[] chars, int value) {
        single = chars;  // set the array of chars
        singlecount = value;  // set the number of chars in array single
        singles = true;  // set flag that single chars are in use
    }

    public final void setCharset(String value)
    {
           // values tells the method whether or not to check for single chars
           boolean more = true;

           // create the arraylists to hold the upper and lower bounds for the char
          // ranges
          lower = new ArrayList(3);
          upper = new ArrayList(3);

          // user has chosen to use all possible characters in the random string
          if (value.compareTo("all") == 0) {
            allchars = true;  // set allchars flag
            // all chars are to be used so there are no single chars to sort
            // through
            more = false;
          }else if ((value.charAt(1) == '-') && (value.charAt(0) != '\\')) {
            // run through the ranges at most 3
            while (more && (value.charAt(1) == '-')){

                    // check to make sure that the dash is not the single char
                       if (value.charAt(0) == '\\')
                           break;
                      else {
                        // add upper and lower ranges to there list
                        lower.add(new Character(value.charAt(0)));
                        upper.add(new Character(value.charAt(2)));
                    }

                    // check to see if there is more to the charset
                    if (value.length() <= 3)
                          more = false;
                    else
                          // create a new string so that the next range if there is one
                       // starts it
                       value = value.substring(3);
             }
        }

        // if more = false there are no single chars in the charset
        if (more) {

            single = new char[30];  // create single

            // create a set of tokens from the string of single chars
            StringTokenizer tokens = new StringTokenizer(value);

            while (tokens.hasMoreTokens()) {
                // get the next token from the string
                String token = tokens.nextToken();

                if (token.length() > 1)
                    // char is a - add it to the list
                    single[singlecount++] = '-';

                // add the current char to the list
                single[singlecount++] = token.charAt(0);
            }
        }
    if ((lower == null) && (single == null))
            setCharset("a-zA-Z0-9");
  }
}

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
色先锋久久av资源部| 国产精品不卡一区| 国产精品久久久久婷婷| 成人伦理片在线| 欧美色综合天天久久综合精品| 精品久久一区二区| 亚洲国产精品一区二区www在线 | 日韩午夜电影在线观看| 日韩美女精品在线| 国产精品一二三四五| 欧美日韩高清一区二区| 亚洲精选在线视频| 成人激情免费视频| 国产欧美精品区一区二区三区| 日韩精品电影在线观看| 在线观看免费成人| 亚洲最大色网站| 色婷婷av久久久久久久| 亚洲视频精选在线| 成人av手机在线观看| 欧美极品aⅴ影院| 国产又粗又猛又爽又黄91精品| 欧美一级日韩免费不卡| 午夜精品久久久久久久久久久| 在线亚洲精品福利网址导航| 亚洲美女少妇撒尿| 色婷婷狠狠综合| 亚洲一区免费视频| 欧美日韩美女一区二区| 亚洲图片欧美视频| 色天使久久综合网天天| 亚洲男同1069视频| 欧洲在线/亚洲| 亚洲午夜久久久久| 欧美精品一卡二卡| 久久精工是国产品牌吗| 欧美精品一区二区三区在线 | 欧美三级中文字| 亚洲综合色自拍一区| 欧美色综合影院| 日韩不卡手机在线v区| 日韩一区二区电影网| 久久精品99国产精品| 久久久久99精品国产片| 成人免费电影视频| 一区二区三区影院| 欧美日本韩国一区二区三区视频| 婷婷中文字幕一区三区| 精品福利二区三区| 成人99免费视频| 亚洲成在线观看| 欧美videos中文字幕| 国产成人99久久亚洲综合精品| 国产精品福利一区| 欧美日韩国产精品成人| 久久精品免费观看| 蜜桃久久av一区| 久久女同互慰一区二区三区| 97精品国产露脸对白| 丝袜亚洲另类欧美| 国产日本亚洲高清| 欧美日韩中字一区| 国产在线精品一区二区不卡了| 国产精品三级视频| 欧美一级高清片| 91在线免费看| 久久精品免费观看| 亚洲精品高清在线观看| 日韩精品专区在线影院观看| 不卡的电影网站| 日韩成人一级片| 亚洲欧洲精品一区二区三区不卡| 91精品国产综合久久香蕉麻豆| 国产精品一区二区黑丝| 亚洲成a人v欧美综合天堂下载| 国产人妖乱国产精品人妖| 欧美另类高清zo欧美| 成人黄色免费短视频| 久久不见久久见中文字幕免费| ●精品国产综合乱码久久久久| 欧美成人vps| 欧美在线不卡视频| 丁香一区二区三区| 精品亚洲成av人在线观看| 亚洲一区二区精品久久av| 国产欧美日韩精品一区| 精品日韩一区二区三区 | 成人h动漫精品| 久久精品国产精品亚洲红杏| 亚洲一区影音先锋| 亚洲丝袜另类动漫二区| 久久久久国产精品麻豆 | 欧美精品三级日韩久久| 不卡一区二区在线| 国产精品白丝av| 久国产精品韩国三级视频| 亚洲不卡av一区二区三区| 亚洲黄一区二区三区| 中文字幕一区在线| 国产精品色哟哟| 国产精品国产自产拍高清av王其 | 国产剧情一区二区| 美女在线一区二区| 日韩av一级电影| 日韩国产高清影视| 日韩专区一卡二卡| 午夜精品在线看| 午夜欧美2019年伦理| 99久久久久免费精品国产| 国产黄色91视频| 国产精品77777| 国产高清精品久久久久| 韩国v欧美v日本v亚洲v| 激情文学综合插| 韩国精品主播一区二区在线观看 | 亚洲色图色小说| 椎名由奈av一区二区三区| 国产精品丝袜黑色高跟| 18成人在线视频| 夜夜嗨av一区二区三区中文字幕| 亚洲日本中文字幕区| 亚洲精品视频自拍| 亚洲图片欧美一区| 日本不卡的三区四区五区| 久久精品国产亚洲aⅴ| 国产一区在线观看视频| 丁香网亚洲国际| 色综合久久久久综合| 欧美日韩mp4| 欧美mv日韩mv| 国产精品毛片无遮挡高清| 亚洲精品高清视频在线观看| 亚洲bt欧美bt精品| 国产综合久久久久久鬼色| 成人久久视频在线观看| 91蝌蚪porny成人天涯| 欧美日韩在线播放三区| 久久亚洲影视婷婷| 亚洲视频综合在线| 日本不卡一二三| 国产成人丝袜美腿| 久久综合色8888| 日韩码欧中文字| 日韩高清国产一区在线| 国产精品伊人色| 欧美私模裸体表演在线观看| 精品精品国产高清一毛片一天堂| 国产精品少妇自拍| 天天综合色天天综合| 成人午夜激情视频| 777欧美精品| 亚洲视频电影在线| 精品在线视频一区| 97久久久精品综合88久久| 欧美一区二区三区爱爱| 国产精品久久国产精麻豆99网站| 亚洲成人黄色影院| 成人黄色在线看| 日韩欧美黄色影院| 一区二区三区在线免费播放 | 日本不卡1234视频| 91色乱码一区二区三区| 欧美不卡在线视频| 亚洲午夜国产一区99re久久| 国产99久久久国产精品潘金网站| 欧美日韩视频在线第一区| 日本一区二区视频在线| 美女视频网站黄色亚洲| 欧美亚一区二区| 中文字幕一区二区日韩精品绯色| 精品一区二区久久久| 欧美日韩国产高清一区二区三区 | 国产精品久久一级| 久久成人综合网| 欧美日韩国产美女| 亚洲精品国产高清久久伦理二区| 国产福利不卡视频| 日韩欧美国产综合| 午夜精品久久久久影视| 91久久精品一区二区二区| 日本一区二区三区电影| 黑人精品欧美一区二区蜜桃 | 亚洲欧洲三级电影| 国产成人av电影在线| 久久精品在线免费观看| 精品一区二区三区在线视频| 成人欧美一区二区三区小说| 国产一区二区三区四| 精品欧美一区二区在线观看| 奇米精品一区二区三区四区| 欧美另类z0zxhd电影| 亚洲成人动漫av| 欧美日本国产视频| 首页亚洲欧美制服丝腿| 3d动漫精品啪啪1区2区免费 | 日韩欧美成人一区| 久久精品国产色蜜蜜麻豆| 日韩欧美成人激情| 国产一区二区免费看| 国产亚洲欧洲997久久综合 |