How to generate a random string, and specify the length you want, or better generate unique string on specification you want

前端 未结 11 2326
一生所求
一生所求 2020-12-24 06:24

There is a library to generate Random numbers, so why isn\'t there a library for generation of random strings?

In other words how to generate a random string, and sp

11条回答
  •  野趣味
    野趣味 (楼主)
    2020-12-24 07:01

    You've sort of answered your own question; there is no RandomString() function because you can use a random number generator to generate a string easily.

    1) Make the range of numbers between the ASCII characters that you wish to include

    2) Append each character to a string until the desired length is reached.

    3) Rise and repeat for each string needed (add them to an array, etc.)

    Surely that'd do it?

提交回复
热议问题