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

Method signPath

examples/signature.java:26–37  ·  view source on GitHub ↗
(byte[] key, byte[] salt, String path)

Source from the content-addressed store, hash-verified

24 }
25
26 public static String signPath(byte[] key, byte[] salt, String path) throws Exception {
27 final String HMACSHA256 = "HmacSHA256";
28
29 Mac sha256HMAC = Mac.getInstance(HMACSHA256);
30 SecretKeySpec secretKey = new SecretKeySpec(key, HMACSHA256);
31 sha256HMAC.init(secretKey);
32 sha256HMAC.update(salt);
33
34 String hash = Base64.getUrlEncoder().withoutPadding().encodeToString(sha256HMAC.doFinal(path.getBytes()));
35
36 return "/" + hash + path;
37 }
38
39 private static byte[] hexStringToByteArray(String hex){
40 if (hex.length() % 2 != 0)

Calls

no outgoing calls

Tested by

no test coverage detected