diff options
-rw-r--r-- | .gitignore | 6 | ||||
-rw-r--r-- | src/org/traccar/helper/Hashing.java | 9 |
2 files changed, 9 insertions, 6 deletions
diff --git a/.gitignore b/.gitignore index 3fe98582b..fde2c462f 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,6 @@ -/target +target +nbactions.xml .classpath .project -.settings/ +.settings +web/.idea diff --git a/src/org/traccar/helper/Hashing.java b/src/org/traccar/helper/Hashing.java index 7e7579ede..3f3e30e6e 100644 --- a/src/org/traccar/helper/Hashing.java +++ b/src/org/traccar/helper/Hashing.java @@ -1,19 +1,20 @@ package org.traccar.helper; -import java.nio.charset.StandardCharsets; +import java.io.UnsupportedEncodingException; 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)); - + md.update(text.getBytes("UTF-8")); return md.digest(); } catch (NoSuchAlgorithmException e) { throw new RuntimeException(e); + } catch (UnsupportedEncodingException e) { + throw new RuntimeException(e); } } |