Question

I read about the UUID v4 and it's virtually unique, and that's what I need. The problem is, it's a too large number, is it possible to generate UUID's like Facebook or Twitter with fewer characters?

I read some post, where you can shrink this code to 20 with Ascii85, but don't see a reliable PHP script doing the job. Someone knows a tested class?? for random ID's it the best way to store this 20 char, right?

--- Edit ---

@David Schwartz

Thanks. I need a random unique identifier in a single server, between 8 and 16 chars (ok 20 is fine if its the lowest). The idea it's to identify objets with readable ID's but NOT incrementals (first objet 10001, second 10002), the way 542A4B243J, C63426KJ70, O30V4U1I9P, etc is fine. The ID's are needed to be primary keys on (at least) 6 MySQL tables. Objets are created with PHP in the same server.

@ta.speot.is

I wrote "don't see a reliable PHP script doing the job. Someone knows a tested class??" I don't think everything code in appear in google are tested, have you tested all the links maybe??

@sarnold

Thanks but I'm sorry, didn't understood well =(

No correct solution

OTHER TIPS

I faced the same problem for an enterprise project I was working on, and I couldn't find a reasonable tested and fast solution in PHP. So I decided to write a PHP extension which can be used to encode/decode data with base85/ascii85.

You can check it out here: https://github.com/miezuit/php-base85

It is tested using a set of automated tests.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top