Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
O
Openfire
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Administrator
Openfire
Commits
ccfee2ea
Commit
ccfee2ea
authored
Jan 05, 2016
by
Guus der Kinderen
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Default to strong RNG for random strings.
parent
c58efa58
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
5 additions
and
8 deletions
+5
-8
StringUtils.java
src/java/org/jivesoftware/util/StringUtils.java
+5
-8
No files found.
src/java/org/jivesoftware/util/StringUtils.java
View file @
ccfee2ea
...
...
@@ -30,6 +30,7 @@ import java.net.IDN;
import
java.nio.charset.StandardCharsets
;
import
java.security.MessageDigest
;
import
java.security.NoSuchAlgorithmException
;
import
java.security.SecureRandom
;
import
java.text.BreakIterator
;
import
java.text.MessageFormat
;
import
java.util.ArrayList
;
...
...
@@ -515,11 +516,9 @@ public final class StringUtils {
}
/**
* Pseudo-random number generator object for use with randomString().
* The Random class is not considered to be cryptographically secure, so
* only use these random Strings for low to medium security applications.
* A cryptographically strong random number generator object for use with randomString().
*/
private
static
Random
randGen
=
new
Random
();
private
static
Random
randGen
=
new
Secure
Random
();
/**
* Array of numbers and letters of mixed case. Numbers appear in the list
...
...
@@ -532,10 +531,8 @@ public final class StringUtils {
/**
* Returns a random String of numbers and letters (lower and upper case)
* of the specified length. The method uses the Random class that is
* built-in to Java which is suitable for low to medium grade security uses.
* This means that the output is only pseudo random, i.e., each number is
* mathematically generated so is not truly random.
* of the specified length. The method uses a cryptographically strong
* random number generator as provided by {@link SecureRandom}
* <p>
* The specified length must be at least one. If not, the method will return
* null.</p>
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment