PHP Get a Random 32 bit token

Using mt_rand() to get a random integer, then calculating the md5 checksum of that integer provides a nice return value for a random 32-bit token.

These tokens can be used as public keys for data that isn't highly sensitive but you still want to secure in some fashion.

They also store nicely in a 16 bit VARBINARY database field, after you apply the UNHEX() function to them.
Posted by
Snippet Viewed 2063 times.

Share your PHP code snippets:

  • Get some recognition & link back to your site.


Submit | Browse

Most Recent php snippets

Most Viewed