Generate a 64-bit number (as a hex string)

php

Solution

Do you mean something like this?

$id = bin2hex(openssl_random_pseudo_bytes(8));

It generates a hex representation of a 64 bit random number.

Problem

I'm reading the android docs specifically http://developer.android.com/reference/android/provider/Settings.Secure.html#ANDROID_ID . I'd like to emulate this function to generate an android_id value in PHP for use in a little test script. It seems all values are 16 characters long and alphanumeric. I want my value to be perfectly valid rather than just generating an alphanumeric 16 character string. Any ideas would be appreciated. Based on Tom's contribution below can someone confirm that the code, bin2hex(openssl_random_pseudo_bytes(8)); would return a perfectly valid android_id

Original source