This question already has an answer here:
What's the shortest way (within reason) to generate a random alpha-numeric (uppercase, lowercase, and numbers) string in JavaScript to use as a probably-unique identifier?
This question already has an answer here:
What's the shortest way (within reason) to generate a random alpha-numeric (uppercase, lowercase, and numbers) string in JavaScript to use as a probably-unique identifier?
This is cleaner
Example
I just came across this as a really nice and elegant solution:
Or to build upon what Jar Jar suggested, this is what I used on a recent project (to overcome length restrictions):
Use:
for 32 characters:
Another variation of answer suggested by JAR.JAR.beans
By changing multiplicator
1e32
you can change length of random string.Nice and simple, and not limited to a certain number of characters: