diff options
author | Demian <demianalonso@gmail.com> | 2015-06-09 19:51:50 -0300 |
---|---|---|
committer | Demian <demianalonso@gmail.com> | 2015-06-09 19:51:50 -0300 |
commit | 96a2d024658746f50628727f7255c4e19ecdb1b4 (patch) | |
tree | fc9642ed3159dd16ebd1c5448233b251b091921c /src/org/traccar/model | |
parent | 62048ed5ec8054c9e0205f3308d0954926746866 (diff) | |
download | trackermap-server-96a2d024658746f50628727f7255c4e19ecdb1b4.tar.gz trackermap-server-96a2d024658746f50628727f7255c4e19ecdb1b4.tar.bz2 trackermap-server-96a2d024658746f50628727f7255c4e19ecdb1b4.zip |
Moved hashing function to a separate helper class
Diffstat (limited to 'src/org/traccar/model')
-rw-r--r-- | src/org/traccar/model/User.java | 21 |
1 files changed, 2 insertions, 19 deletions
diff --git a/src/org/traccar/model/User.java b/src/org/traccar/model/User.java index 9186e66c5..410bc4d74 100644 --- a/src/org/traccar/model/User.java +++ b/src/org/traccar/model/User.java @@ -15,9 +15,7 @@ */ package org.traccar.model; -import java.io.UnsupportedEncodingException; -import java.security.MessageDigest; -import java.security.NoSuchAlgorithmException; +import org.traccar.helper.Hashing; public class User implements Factory { @@ -40,7 +38,7 @@ public class User implements Factory { private byte[] password; public byte[] getPassword() { return password; } - public void setPassword(String password) { this.password = sha256(password); } + public void setPassword(String password) { this.password = Hashing.sha256(password); } private boolean readonly; @@ -61,19 +59,4 @@ public class User implements Factory { private double longitude; private int zoom; - - - public static byte[] sha256(String text) { - try { - MessageDigest md = MessageDigest.getInstance("SHA-256"); - - md.update(text.getBytes("UTF-8")); - byte[] digest = md.digest(); - return digest; - } catch (NoSuchAlgorithmException e) { - throw new RuntimeException(e); - } catch (UnsupportedEncodingException e) { - throw new RuntimeException(e); - } - } } |