I used the function below to calculate a hash of password. My problem is when I try to print hashcode I get an array of int even that the hash variable is of type String.
private static String getHashCode(String password) {
String hash = "";
try {
MessageDigest md5 = MessageDigest.getInstance("SHA-512");
byte [] digest = md5.digest(password.getBytes("UTF-8"));
hash = Arrays.toString(digest);
} catch (UnsupportedEncodingException e) {
e.printStackTrace();
} catch (NoSuchAlgorithmException e) {
e.printStackTrace();
}
System.out.println(hash);
return hash;
}