Shorter UUID, ASCII85 with PHP

I read about UUID v4 , and it is almost unique, and that is what I need. The problem is that this number is too large, is it possible to generate UUIDs like Facebook or Twitter with fewer characters?

I read a post where you can compress this code to 20 using Ascii85, but don’t see a reliable PHP script doing this job. Does anyone know a proven class? for a random ID, this is the best way to save this 20 char, right?

--- Edit ---

@ David Schwartz

Thanks. I need a random unique identifier on the same server, between 8 and 16 characters (ok 20 is great if it's the lowest). The idea is to identify objects with a readable identifier, but not increments (first object 10001, second 10002), method 542A4B243J, C63426KJ70, O30V4U1I9P, etc. In order. Identifiers are needed to be primary keys (at least) in 6 MySQL tables. Objects are created with PHP on the same server.

@ ta.speot.is

I wrote: “I don’t see a reliable PHP script doing the job. Does anyone know a proven class?” I don’t think that all codes appearing in google are tested, you tested all links, maybe?

@sarnold

Thank you, but I'm sorry I did not understand well = (

+2
source share
1 answer

I had the same problem for the corporate project that I was working on, and I could not find a reasonable proven and fast solution in PHP. Therefore, I decided to write a PHP extension that can be used to encode / decode data using base85 / ascii85.

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

It is tested using a set of automated tests.

0
source

Source: https://habr.com/ru/post/1412782/


All Articles