How to really shuffle a deck of cards

后端 未结 5 2171
孤独总比滥情好
孤独总比滥情好 2021-02-04 08:16

When I need to shuffle a deck of poker cards in Java/Android, I use Collections.shuffle(List list), of course. I\'ve ever been doing this and the results s

5条回答
  •  温柔的废话
    2021-02-04 08:50

    Although you are using a SecureRandom, is still has a limited state. As long as that input seed has a smaller range than 52! it can not be completely random.

    In fact, SHA1PRNG is 160 bit seeded, which means it is still not random enough. Follow this link, it has a solution years ago by using a third party library called UnCommons Math.

提交回复
热议问题