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/helper | |
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/helper')
-rw-r--r-- | src/org/traccar/helper/Hashing.java | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/src/org/traccar/helper/Hashing.java b/src/org/traccar/helper/Hashing.java new file mode 100644 index 000000000..7e7579ede --- /dev/null +++ b/src/org/traccar/helper/Hashing.java @@ -0,0 +1,20 @@ +package org.traccar.helper; + +import java.nio.charset.StandardCharsets; +import java.security.MessageDigest; +import java.security.NoSuchAlgorithmException; + +public class Hashing { + + public static byte[] sha256(String text) { + try { + MessageDigest md = MessageDigest.getInstance("SHA-256"); + md.update(text.getBytes(StandardCharsets.UTF_8)); + + return md.digest(); + } catch (NoSuchAlgorithmException e) { + throw new RuntimeException(e); + } + } + +} |