2

Team Sof,

I have a requirement to generate name-based UUIDs for my project. The catch is that FE uses PHP to generate identifiers based on a string, and BE uses Java to create those UUIDs based on same string.

Is there some package in PHP and Java that generate same UUID based on a string. I tried to generate UUID in Java using UUID.nameUUIDFromBytes(name.getBytes()).toString() method from java.util.UUID. In case of PHP, I am finding a module that generates same UUID

Prasanth
  • 5,230
  • 2
  • 29
  • 61
Code4Fun
  • 125
  • 3
  • 13

1 Answers1

4

Java's UUID.nameUUIDFromBytes returns a Variant 3 UUID, Ben Ramsey's Ramsey\Uuid PHP library can generate these.

tristanbailey
  • 4,427
  • 1
  • 26
  • 30
Anthony Sterling
  • 2,451
  • 16
  • 10
  • Thanks for mentioning my [Rhumsaa\Uuid](https://github.com/ramsey/uuid) library. Unfortunately, the link above is broken (I moved files around for PSR-4), but the library is still alive and well. It can generate version 3 and 5 UUIDs and is fully compatible with all RFC 4122 UUIDs. If you create a name-based version 3 or 5 UUID in any other programming language, this library is able to generate the same UUID, given the same "name space" and "name." – ramsey Feb 28 '14 at 14:54
  • 1
    I changed the link for you @ramsey so the link works – tristanbailey Aug 14 '15 at 14:21