I am trying to get the hash value for a string using MessageDigest in Java, but the value changes every time. When I run the program twice, it will again have different answers.
MessageDigest md = null; try { md = MessageDigest.getInstance("SHA-1"); } catch (NoSuchAlgorithmException nsae) { } md.update("string".getBytes()); byte[] digest = md.digest(); System.out.println(digest); md.reset(); md.update("string".getBytes()); byte[] digest2 = md.digest(); System.out.println(digest2);
source share