php-ulid icon indicating copy to clipboard operation
php-ulid copied to clipboard

Binary Compatibility

Open Lewiscowles1986 opened this issue 9 years ago • 1 comments

https://github.com/alizain/ulid/issues/11

Need to implement binary and API compatibility with original lib.

Unsure if pack can be used, needs tests and toByteArray method.

Lewiscowles1986 avatar Dec 08 '16 20:12 Lewiscowles1986

Actually, it looks like the binary format will change the output of this library

  • https://gist.github.com/bigcalm/4599839 works with 48-bit numbers, but it's the wrong byte-order (no idea if how they are sourcing numbers as well as pack structure is the reason for this).

  • pack("NnnNN", $time32H, $time16L, $random16ubit, $random32ubit1, $random32ubit2) should work, but this means new interfaces are needed to facilitate interfacing with something to split the time and random source (before encoding to string).

  • needs a correctly implemented adder to encode to base32 correctly (maybe there is something that can be used for this)

Lewiscowles1986 avatar Sep 26 '17 13:09 Lewiscowles1986