Does anyone know of any API key generator script/class for PHP? The class should have method generate, that would generate a key and isValid() method, to check if the key is valid.
Does anyone know of any API key generator script/class for PHP? The class should have method generate, that would generate a key and isValid() method, to check if the key is valid.
You can just do something simple like md5(time()) -> and just store the result in a db for future checking
GUID would work but is not cryptographically secure.
Server answers use md5 or sha1 hashing methods on microtime() or mt_rand.
Hashing a uniqid, uuid or timestamp would not necessarily create unique results! Actually hashing increases the chance of collisions so I would strongly advise against this.
If you do not need the API key to mean anything or be decodable, just to match with something, then this works:
$api = md5(time());