Skip to content

Commit

Permalink
changing Math.random to SecureRandom
Browse files Browse the repository at this point in the history
  • Loading branch information
rcaa committed Dec 11, 2016
1 parent 4365c8f commit a1fc7e7
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/main/java/com/gitblit/models/UserModel.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@

import java.io.Serializable;
import java.security.Principal;
import java.security.SecureRandom;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashSet;
Expand Down Expand Up @@ -662,6 +663,9 @@ public boolean isMyPersonalRepository(String repository) {
}

public String createCookie() {
return StringUtils.getSHA1(String.valueOf(Math.random()));
SecureRandom random = new SecureRandom();
byte[] values = new byte[20];
random.nextBytes(values);
return StringUtils.getSHA1(String.valueOf(values));
}
}

0 comments on commit a1fc7e7

Please sign in to comment.