Managing random character strings, preventing re-use, and trying to use as few characters as possible
Hi,
I'm trying to figure out the best method to create a random character string, using typical numbers and letters
0-9 / a-z (non case sensitive)
Goals I am trying to achieve
-will need to query database to see if string is already in use (no biggie if string is found, then repeat until unused string found)
-Can only be up to 5 characters long
-should be as short as possible, no less than 2 characters (if string can only be 2 characters long choose that)
For every string generated, it will be kept in a table..
I need to write a small function to generate these results, so that I can populate the table.
I thought about just doing it in sequence.. 1, 2, 3, 4, etc. using alphabetical characters as well, but I kind of want it to be random.
Any ideas?
Hi,
I'm trying to figure out the best method to create a random character string, using typical numbers and letters
0-9 / a-z (non case sensitive)
Goals I am trying to achieve
-will need to query database to see if string is already in use (no biggie if string is found, then repeat until unused string found)
-Can only be up to 5 characters long
-should be as short as possible, no less than 2 characters (if string can only be 2 characters long choose that)
For every string generated, it will be kept in a table..
I need to write a small function to generate these results, so that I can populate the table.
I thought about just doing it in sequence.. 1, 2, 3, 4, etc. using alphabetical characters as well, but I kind of want it to be random.
Any ideas?