token-validator
You can use it for generating a token that will validate a string (optionally with an expiration).
How it works
The token is formed by an hexadecimal hash and hexadecimal number, separated by a dash. The number is used to check for the expiration time. You can have a look at the algorithm in the source code, it is pretty simple.
How to use it
First of all you have to set up your token-validator object:
var TokenVal = ; var secret = 'I only know this';var duration = 60 * 1000; // in msvar len = 10; // the hash lengthvar tokenVal = secret duration len;
Then you can generate a token:
var token = tokenVal;
and validating it in this way:
var isValid = tokenVal;
If the function is called within the duration of the token this will be valid.