public static byte [ ] generateRandomUUIDBytes ( ) { if ( rand == null ) rand = new SecureRandom ( ) ; byte [ ] buffer = new byte [ 16 ] ; rand . nextBytes ( buffer ) ; // Set version to 3 (Random) buffer [ 6 ] = ( byte ) ( ( buffer [ 6 ] & 0x0f ) | 0x40 ) ; // Set variant to 2 (IETF) buffer [ 8 ] = ( byte ) ( ( buffer [ 8 ] & 0x3f ) | 0x80 ) ; return buffer ; }
Generates a pseudo random UUID and returns it in byte array form .