2

I want generate an account ID ,total user account less than 500K,so i want make account ID as short as possible, so I want know how to generate 8 or 16 characters ID use php ?

Leo
  • 23
  • 1
  • 3

1 Answers1

10

Try this

echo strtoupper(bin2hex(openssl_random_pseudo_bytes(16)));

This will generate 16 characters unique string

You can create common function also

function GUID() {
    return strtoupper(bin2hex(openssl_random_pseudo_bytes(16)));
}
$id = GUID();
echo $id;
Nidhi
  • 1,529
  • 18
  • 28