MCPcopy Create free account
hub / github.com/imgproxy/imgproxy / hexStringToByteArray

Method hexStringToByteArray

examples/signature.java:39–47  ·  view source on GitHub ↗
(String hex)

Source from the content-addressed store, hash-verified

37 }
38
39 private static byte[] hexStringToByteArray(String hex){
40 if (hex.length() % 2 != 0)
41 throw new IllegalArgumentException("Even-length string required");
42 byte[] res = new byte[hex.length() / 2];
43 for (int i = 0; i < res.length; i++) {
44 res[i]=(byte)((Character.digit(hex.charAt(i * 2), 16) << 4) | (Character.digit(hex.charAt(i * 2 + 1), 16)));
45 }
46 return res;
47 }
48}

Calls

no outgoing calls

Tested by

no test coverage detected