A bare-bones php token authentication class
simple token requires nothing more than a base installation of PHP 5.3 and can be easily adapted for use in an API.
-
Generate a key to store on each end
$key = SimpleToken::generateKey();
-
Generate a token to be passed from one end to the other. This token will be good for until the end of the current day. There's a better way to do this, and I'll certainly come back and make it so, someday.
$token = SimpleToken::generateToken($key, $content);
-
Verify the authenticity of the transaction.
if(SimpleToken::isAuthentic($key, $content, $token)) { echo 'Valid'; } else { echo 'Invalid'; }
simple-token is open-sourced software licensed under the MIT License.
- lewsid@lewsid.com
- github.com/lewsid