Skip to content

Commit 72a108f

Browse files
authored
Drop last 4 bytes of computed SHA-1 hash
1 parent 39a2838 commit 72a108f

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

core-java-modules/core-java/src/main/java/com/baeldung/uuid/UUIDGenerator.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ public static UUID type5UUIDFromBytes(byte[] name) {
6767
} catch (NoSuchAlgorithmException nsae) {
6868
throw new InternalError("MD5 not supported", nsae);
6969
}
70-
byte[] bytes = md.digest(name);
70+
byte[] bytes = Arrays.copyOfRange(md.digest(name), 0, 16);
7171
bytes[6] &= 0x0f; /* clear version */
7272
bytes[6] |= 0x50; /* set to version 5 */
7373
bytes[8] &= 0x3f; /* clear variant */

0 commit comments

Comments
 (0)