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 3
3
import java .io .UnsupportedEncodingException ;
4
4
import java .security .MessageDigest ;
5
5
import java .security .NoSuchAlgorithmException ;
6
+ import java .util .Arrays ;
6
7
import java .util .UUID ;
7
8
8
9
public class UUIDGenerator {
@@ -65,9 +66,9 @@ public static UUID type5UUIDFromBytes(byte[] name) {
65
66
try {
66
67
md = MessageDigest .getInstance ("SHA-1" );
67
68
} catch (NoSuchAlgorithmException nsae ) {
68
- throw new InternalError ("MD5 not supported" , nsae );
69
+ throw new InternalError ("SHA-1 not supported" , nsae );
69
70
}
70
- byte [] bytes = md .digest (name );
71
+ byte [] bytes = Arrays . copyOfRange ( md .digest (name ), 0 , 16 );
71
72
bytes [6 ] &= 0x0f ; /* clear version */
72
73
bytes [6 ] |= 0x50 ; /* set to version 5 */
73
74
bytes [8 ] &= 0x3f ; /* clear variant */
You can’t perform that action at this time.
0 commit comments