Should I seed a SecureRandom?

前端 未结 5 837
忘了有多久
忘了有多久 2021-01-17 07:09

Found the following code in our code base:

public static final int DEFAULT_LENGTH = 16;
private static SecureRandom SR;
static
{
   try
   {
      SecureRand         


        
5条回答
  •  终归单人心
    2021-01-17 07:45

    Just an addendum to this answer. According to Google, if you are using this code in android you should definitely seed the SecureRandom using a high entropy source like /dev/urandom or /dev/random.

    Even the post below is an year old now, perhaps this has already been corrected but I couldn't confirm if it was.

    https://plus.google.com/+AndroidDevelopers/posts/YxWzeNQMJS2

    EDIT:

    It seems that the default behavior of the class is now the one specified in the post so seeding is again deemed unnecessary:

    http://developer.android.com/reference/java/security/SecureRandom.html

提交回复
热议问题