How to generate a secure random alphanumeric string in Java efficiently?

后端 未结 9 1479
半阙折子戏
半阙折子戏 2021-01-01 12:24

How do you generate a secure random (or pseudo-random) alphanumeric string in Java efficiently?

9条回答
  •  再見小時候
    2021-01-01 13:02

    If you use Apache Commons Lang, the easiest way is

    RandomStringUtils.random(20, 0, 0, true, true, null, new SecureRandom());
    

提交回复
热议问题