How to deal with a slow SecureRandom generator?

后端 未结 17 1219
时光说笑
时光说笑 2020-11-22 11:56

If you want a cryptographically strong random numbers in Java, you use SecureRandom. Unfortunately, SecureRandom can be very slow. If it uses

17条回答
  •  陌清茗
    陌清茗 (楼主)
    2020-11-22 12:44

    You should be able to select the faster-but-slightly-less-secure /dev/urandom on Linux using:

    -Djava.security.egd=file:/dev/urandom
    

    However, this doesn't work with Java 5 and later (Java Bug 6202721). The suggested work-around is to use:

    -Djava.security.egd=file:/dev/./urandom
    

    (note the extra /./)

提交回复
热议问题