在Linux下,如果你使用 java.security 包中的方法(比如SecureKeyFactory.generateSecret()),会发现它出奇的慢,有时候甚至是半僵死在那里。
有两个方法解决这个问题
securerandom.source=file:/dev/./urandom
[root@linux ~]# yum install rng-tools
[root@linux ~]# echo 'EXTRAOPTIONS="-i -o /dev/random -r /dev/urandom -t 10 -W 2048"' > /etc/sysconfig/rngd
[root@linux ~]# chkconfig rngd on
[root@linux ~]# service rngd restart
参考:http://development.adaptris.com/~lchan/blog/2012/06/15/slow-java-crypto-performance-on-linux/