From ae56bc9e1f212bf96c3573b43fb8b11983bbb3e1 Mon Sep 17 00:00:00 2001 From: Anton Tananaev Date: Wed, 10 Jun 2015 19:21:31 +1200 Subject: Fix Hashing Java 6 support --- src/org/traccar/helper/Hashing.java | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) (limited to 'src') 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); } } -- cgit v1.2.3