问题:
I've been looking for a simple Java algorithm to generate a pseudo-random alpha-numeric string. 我一直在寻找一种简单的 Java算法来生成伪随机的字母数字字符串。 In my situation it would be used as a unique session/key identifier that would "likely" be unique over 500K+
generation (my needs don't really require anything much more sophisticated). 在我的情况下,它将用作唯一的会话/密钥标识符,在“超过500K+
世代中“可能”是唯一的(我的需求实际上不需要任何更复杂的东西)。
Ideally, I would be able to specify a length depending on my uniqueness needs. 理想情况下,我可以根据自己的独特性要求指定长度。 For example, a generated string of length 12 might look something like "AEYGF7K0DM1X"
. 例如,生成的长度为12的字符串可能看起来像"AEYGF7K0DM1X"
。
解决方案:
参考一: https://stackoom.com/question/Ah1/如何生成随机的字母数字字符串参考二: https://oldbug.net/q/Ah1/How-to-generate-a-random-alpha-numeric-string
来源:oschina
链接:https://my.oschina.net/stackoom/blog/4301508