diff --git a/src/main/java/w2phtml/base/ImageConverter.java b/src/main/java/w2phtml/base/ImageConverter.java
index 011f07b..8fb8cfa 100644
--- a/src/main/java/w2phtml/base/ImageConverter.java
+++ b/src/main/java/w2phtml/base/ImageConverter.java
@@ -33,7 +33,7 @@ import java.util.Arrays;
import java.util.HashMap;
import java.util.HashSet;
-import javax.xml.bind.DatatypeConverter;
+import java.util.Base64;
import org.w3c.dom.Element;
import org.w3c.dom.Node;
@@ -253,9 +253,9 @@ public final class ImageConverter {
buf.append(nl.item(i).getNodeValue());
}
}
- //blob = Base64.decode(buf.toString());
- blob = DatatypeConverter.parseBase64Binary(buf.toString());
- // We may have seen this image before, return the recycled version
+ blob = Base64.getDecoder().decode(buf.toString());
+ //blob = DatatypeConverter.parseBase64Binary(buf.toString());
+ // We may have seen this image before, return the recycled version
String sId1 = createId(blob);
if (recycledImages.containsKey(sId1)) {
return recycledImages.get(sId1);
@@ -347,8 +347,18 @@ public final class ImageConverter {
// This would be surprising
return null;
}
- return DatatypeConverter.printHexBinary(md.digest(blob))
- +DatatypeConverter.printHexBinary(Arrays.copyOf(blob, 10));
+ return bytesToHex(md.digest(blob)) + bytesToHex(Arrays.copyOf(blob, 10));
+ }
+
+ private static final char[] HEX_ARRAY = "0123456789ABCDEF".toCharArray();
+ public static String bytesToHex(byte[] bytes) {
+ char[] hexChars = new char[bytes.length * 2];
+ for (int j = 0; j < bytes.length; j++) {
+ int v = bytes[j] & 0xFF;
+ hexChars[j * 2] = HEX_ARRAY[v >>> 4];
+ hexChars[j * 2 + 1] = HEX_ARRAY[v & 0x0F];
+ }
+ return new String(hexChars);
}
}