Closed (fixed)
Project:
Token
Version:
6.x-1.x-dev
Component:
Code
Priority:
Normal
Category:
Feature request
Assigned:
Unassigned
Reporter:
Created:
22 Nov 2007 at 09:14 UTC
Updated:
9 Dec 2011 at 11:18 UTC
Jump to comment: Most recent file
Comments
Comment #1
gregglesMarked #247204: (pseudo) random number token as a duplicate.
Comment #2
coltraneSubscribing
Comment #3
dave reidSetting appropriate status.
Comment #4
grah commentedsubscribing
Comment #5
coltraneI can see several use cases that would need different random tokens. What all should token provide?
In issue #247204: (pseudo) random number token there is discussion about various tokens that could be strung together to define a certain length.
A recent case I needed was a token for use in pathauto to make a random URL.
Some example tokens:
Random numbers, one, three, or five digits (could go on).
rand-num-1
rand-num-3
rand-num-5
Random alphabetical letters, one, three, or five characters (could go on).
rand-alpha-1
rand-alpha-3
rand-alpha-5
Using the above tokens could lead to more collisions I think and shouldn't be counted on for security.
What about the case where a 32 character hash from a sha1 token is too long? Should token provide truncated hashes, like [sha1-16] for a
substr(sha1(mt_rand()), 0, 15)?Edit: catching my off-by-one bug
Comment #6
gregglesMaybe 1, 3, 10 would be good?
I don't understand the use-cases for the SHA1 so I don't know whether it should be 16 or 32 or...something else.
I think we shouldn't worry too much and should just start providing them.
BTW - eaton and I discussed this a bit and agree that a "tokenSTARTER.module" is the best way to provide this. Then we need some docs to describe to people how to take the tokenSTARTER.module and turn it into their own fun thing (like Zen does). These random number/string tokens are a perfect point to start that module. Of course that's a lot more work - I'd be happy to build it/document it myself and then just add these in as a patch to that module...
Comment #7
coltrane1, 3, and 10 sound fine. I see use for a SHA1 token, but maybe a shortened one off a hash is too specific, or could be handled fine without collisions by stringing together rand-alpha tokens. I plan to roll a patch against the 6.x dev branch.
Comment #8
B747 commentedHi,
Is this in the dev version yet please?
Comment #9
gregglesI've committed a 32 character sha1 in #437842: create a token starterkit module and documentation so people know how to use it.
@coltrane - if you can add your random tokens in there it would be great. Thanks!
Comment #10
coltraneComment #11
coltrane"Hey there status select! How are you? Sorry I forgot you :("
Comment #12
coltraneHere's #10 with 1, 3, and 10 letters.
Comment #13
gregglesThank you, sir! http://drupal.org/cvs?commit=211630
Comment #15
batigolixTo use the random number token in modules like pathauto you need to define the random token in a custom module. E.g. as follows:
check tokenSTARTER.module in the token module folder for more examples of random numbers