(byte[] key, byte[] salt, String path)
| 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) |
no outgoing calls
no test coverage detected