aboutsummaryrefslogtreecommitdiff
path: root/src/org/traccar/helper/Hashing.java
diff options
context:
space:
mode:
Diffstat (limited to 'src/org/traccar/helper/Hashing.java')
-rw-r--r--src/org/traccar/helper/Hashing.java14
1 files changed, 9 insertions, 5 deletions
diff --git a/src/org/traccar/helper/Hashing.java b/src/org/traccar/helper/Hashing.java
index beb674b00..1f01d9102 100644
--- a/src/org/traccar/helper/Hashing.java
+++ b/src/org/traccar/helper/Hashing.java
@@ -15,12 +15,12 @@
*/
package org.traccar.helper;
-import javax.crypto.SecretKeyFactory;
-import javax.crypto.spec.PBEKeySpec;
import java.security.GeneralSecurityException;
import java.security.SecureRandom;
+import javax.crypto.SecretKeyFactory;
+import javax.crypto.spec.PBEKeySpec;
-public class Hashing {
+public final class Hashing {
public static final int ITERATIONS = 1000;
public static final int SALT_SIZE = 24;
@@ -45,6 +45,9 @@ public class Hashing {
}
}
+ private Hashing() {
+ }
+
private static byte[] function(char[] password, byte[] salt) {
try {
PBEKeySpec spec = new PBEKeySpec(password, salt, ITERATIONS, HASH_SIZE * Byte.SIZE);
@@ -55,10 +58,11 @@ public class Hashing {
}
}
- private static final SecureRandom random = new SecureRandom();
+ private static final SecureRandom RANDOM = new SecureRandom();
public static HashingResult createHash(String password) {
- byte[] salt = new byte[SALT_SIZE]; random.nextBytes(salt);
+ byte[] salt = new byte[SALT_SIZE];
+ RANDOM.nextBytes(salt);
byte[] hash = function(password.toCharArray(), salt);
return new HashingResult(
ChannelBufferTools.convertByteArray(hash),