A random string that generates the specified length within the specified range

xiaoxiao2021-03-06  39

A random string that generates the specified length within the specified range

The previous time writes a random number of random number generated within the specified range, the following class generated random string

The idea is very simple, the code is as follows:

/ * * Create a date 2004-12-22 * * /

/ ** * Standby random string of designated length within the specified range * * @Author wubai * * * / public class getrandomstr {

/ ** * * Generate a random string of normally positioned * @Param Randomlen returned the length * @return random string * / public string getrandomstr (int Randomlease "{// basic data, you can modify String as needed [] base = {"A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L", " M "," N "," O "," P "," Q "," R "," S "," T "," V "," U "," W "," X "," Y " , "Z", "A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", " L "," M "," N "," O "," P "," Q "," R "," S "," T "," V "," U "," W "," X " "Y", "Z", "0", "1", "2", "3", "4", "6", "7", "8", "9", " ! "," @ "," # "," $ ","% "," ^ "," & "," * "," (","}; // To return string string randomstr = ""; // basic data number INT size = base.length;

// Random array subscript int TMP;

转载请注明原文地址:https://www.9cbs.com/read-78019.html

New Post(0)