I’m trying to create a Version 1 UUID based on a mac address as defined on page 8 of RFC 4122 using only PHP. Another answer on this site recommended this implementation which seems to fit the bill.
I’m testing the usage of this class as follows:
<?php
echo UUID::generate(UUID::UUID_TIME, UUID::FMT_STRING, '000000000000');
?>
But I’m getting the following output:
6c10f140-28c0-11e2-a210-303030303030
My understanding of the standard is that the node (last part) should be the mac address verbatim. Looking at the source code it seems to use ord() which looks like it gets the ASCII value of the characters in the string provided to generate the node instead of using the address itself?
Is my understanding of the spec wrong or is the code wrong?
You need to pass it in binary form:
This is why the loop goes 6 times, 6 bytes = 48 bits.