class GlobalIdentifier {

  public static byte[] toBytes(final String guid)
  {
    // CheckStyle:MagicNumber OFF

    // remove the enclosing brackets {...}
    final StringTokenizer st = new StringTokenizer(guid.substring(1, guid.length() - 1), "-");
    // first token is 4 bytes, big endian
    final String data1 = st.nextToken();
    // second token is 2 bytes, big endian
    final String data2 = st.nextToken();
    // third token is 2 bytes, big endian
    final String data3 = st.nextToken();
    // fourth token is 2 bytes, little endian
    final String data4 = st.nextToken();
    // fifth token is 6 bytes, little endian
    final String data5 = st.nextToken();

    final ByteBuffer guidBuffer = ByteBuffer.allocate(16);
    putBytes(guidBuffer, LdapUtils.hexDecode(data1.toCharArray()), true);
    putBytes(guidBuffer, LdapUtils.hexDecode(data2.toCharArray()), true);
    putBytes(guidBuffer, LdapUtils.hexDecode(data3.toCharArray()), true);
    putBytes(guidBuffer, LdapUtils.hexDecode(data4.toCharArray()), false);
    putBytes(guidBuffer, LdapUtils.hexDecode(data5.toCharArray()), false);

    return guidBuffer.array();
    // CheckStyle:MagicNumber ON
  }

  private  GlobalIdentifier();

}