I need to create an unique token for a web service. I'm doing that in the following in the following way:
var element_id // auto increment number, every time different var secret_key // an secret key var random_key // a random generated string of 8 chars, every time different var timestamp // the timestamp at the moment of generation var token = element_id + secret_key + random_key + timestamp;
This will produce a string consisting of 15 to 20 characters. In my system every string generated in this way is unique.
Then I create the SHA-256 version of that string
sha256_token be unique in my system as it was the "clear"