· 9 years ago · Dec 17, 2016, 02:05 PM
1protected String hashToString(String url, byte[] secretKey) {
2
3 String result = null;
4
5 Mac sha512_HMAC;
6
7 try {
8
9 sha512_HMAC = Mac.getInstance("HmacSHA512");
10
11
12 SecretKeySpec secretkey = new SecretKeySpec(secretKey, "HmacSHA512");
13
14 sha512_HMAC.init(secretkey);
15
16 byte[] mac_data = sha512_HMAC.doFinal(url.getBytes());
17
18 result = Base64.encodeBase64String(mac_data);
19
20 }catch(Exception e){
21 }
22 return result;
23 }