File tree Expand file tree Collapse file tree 1 file changed +3
-2
lines changed
core-java-modules/core-java/src/main/java/com/baeldung/uuid Expand file tree Collapse file tree 1 file changed +3
-2
lines changed Original file line number Diff line number Diff line change 33import java .io .UnsupportedEncodingException ;
44import java .security .MessageDigest ;
55import java .security .NoSuchAlgorithmException ;
6+ import java .util .Arrays ;
67import java .util .UUID ;
78
89public class UUIDGenerator {
@@ -65,9 +66,9 @@ public static UUID type5UUIDFromBytes(byte[] name) {
6566 try {
6667 md = MessageDigest .getInstance ("SHA-1" );
6768 } catch (NoSuchAlgorithmException nsae ) {
68- throw new InternalError ("MD5 not supported" , nsae );
69+ throw new InternalError ("SHA-1 not supported" , nsae );
6970 }
70- byte [] bytes = md .digest (name );
71+ byte [] bytes = Arrays . copyOfRange ( md .digest (name ), 0 , 16 );
7172 bytes [6 ] &= 0x0f ; /* clear version */
7273 bytes [6 ] |= 0x50 ; /* set to version 5 */
7374 bytes [8 ] &= 0x3f ; /* clear variant */
You can’t perform that action at this time.
0 commit comments