Is there any good way to generate 100,000 non-repeated 13-bit pure numeric strings? is there any good way to generate 100,000 non-repeated 13-bit pure numeric strings?
Reply content:
Is there any good way to generate 100,000 unique 13-bit pure numeric strings?
One by one. Starting from 13 0, add 1 at a time...
It can be generated by time stamps, or a random number is added later.
Package com. xtl. demo; import java. util. hashSet; import java. util. random; import java. util. set; /*** generate 20 non-repeated 13-digit random numbers * @ author xiatianlong ** @ date 11:44:57 on April 9, October 8, 2016 */public class CreatRandomNumber {public static void main (String [] args) {Set
NumberSet = new HashSet
(); While (true) {// if (numberSet. size ()> 20) {break;} String randomNumber = createRandomNumber (13); numberSet. add (randomNumber);} for (String string: numberSet) {System. out. println (string) ;}}/*** generate a random number of specified digits * @ param length * The number of digits generated * @ return */public static String createRandomNumber (int length) {String number = ""; for (int I = 0; I
Performance is not considered...
You can encrypt characters in one direction and add salt to them. you can only get 13 characters.
Available in pythonrandom.sample:
random.sample(range(10**12, 10**13), 10**5)
Python2xrangeIf you want to start from scratchformat.