aboutsummaryrefslogtreecommitdiff
path: root/src/org/traccar/helper/Hashing.java
diff options
context:
space:
mode:
authorAnton Tananaev <anton.tananaev@gmail.com>2015-10-26 13:11:19 +1300
committerAnton Tananaev <anton.tananaev@gmail.com>2015-10-26 13:11:19 +1300
commit3e56ea6a99e7da5d61c5956876c2d977268e4756 (patch)
treef70f61b1ec218e4491d36c10d5fbd52a67ba4862 /src/org/traccar/helper/Hashing.java
parentfbdd359d223579173b4e0076563df296f5492e3c (diff)
downloadtrackermap-server-3e56ea6a99e7da5d61c5956876c2d977268e4756.tar.gz
trackermap-server-3e56ea6a99e7da5d61c5956876c2d977268e4756.tar.bz2
trackermap-server-3e56ea6a99e7da5d61c5956876c2d977268e4756.zip
Use standard Java hex conversion
Diffstat (limited to 'src/org/traccar/helper/Hashing.java')
-rw-r--r--src/org/traccar/helper/Hashing.java9
1 files changed, 5 insertions, 4 deletions
diff --git a/src/org/traccar/helper/Hashing.java b/src/org/traccar/helper/Hashing.java
index cdc5c7ae5..29020f3a7 100644
--- a/src/org/traccar/helper/Hashing.java
+++ b/src/org/traccar/helper/Hashing.java
@@ -19,6 +19,7 @@ import java.security.GeneralSecurityException;
import java.security.SecureRandom;
import javax.crypto.SecretKeyFactory;
import javax.crypto.spec.PBEKeySpec;
+import javax.xml.bind.DatatypeConverter;
public final class Hashing {
@@ -65,13 +66,13 @@ public final class Hashing {
RANDOM.nextBytes(salt);
byte[] hash = function(password.toCharArray(), salt);
return new HashingResult(
- ChannelBufferTools.bytesToHex(hash),
- ChannelBufferTools.bytesToHex(salt));
+ DatatypeConverter.printHexBinary(hash),
+ DatatypeConverter.printHexBinary(salt));
}
public static boolean validatePassword(String password, String hashHex, String saltHex) {
- byte[] hash = ChannelBufferTools.hexToBytes(hashHex);
- byte[] salt = ChannelBufferTools.hexToBytes(saltHex);
+ byte[] hash = DatatypeConverter.parseHexBinary(hashHex);
+ byte[] salt = DatatypeConverter.parseHexBinary(saltHex);
return slowEquals(hash, function(password.toCharArray(), salt));
}