Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- protected String hashToString(String serializedModel, byte[] key) {
- String result = null;
- Mac sha512_HMAC;
- try {
- sha512_HMAC = Mac.getInstance("HmacSHA512");
- SecretKeySpec secretkey = new SecretKeySpec(key, "HmacSHA512");
- sha512_HMAC.init(secretkey);
- byte[] mac_data = sha512_HMAC.doFinal(serializedModel.getBytes("UTF-8"));
- // if this next line not compiled, test the second line.
- result = Base64.encodeBase64String(mac_data);
- //result = Base64.encodeToString(mac_data, Base64.DEFAULT);
- }catch(Exception e){
- }
- return result;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement