Cosmos75
Registered User.
- Local time
- Today, 12:26
- Joined
- Apr 22, 2002
- Messages
- 1,280
I have code that generates a random alphanumeric string.
Say I am generating a 4 character alphanumeric string.
The code loops and generates the first character, checks if it can create any more passwords with that character.
If it can, it stores this character, it continues the loop to generate the second alphanumeric character.
If it can’t, it starts all over again at the first character.
What I would like to do is to somehow store the character(s) that the code determines is unusable as opposed to doing running through the code again. How would I accomplish that? Store it in an array?
Right now the way I am accomplishing that is to have it look at the strinig in the table with the right length of characters. If it is generating the first character, then count the number of records that have the start with the same character (or characters) that is generated (matching upper or lower case as well) and then count the number of records it finds and see if it is less than the total possible alphanumeric strings that begin with the generated first character (or first two characters if we are on the second character of the stringand so on)
Say at the point the code determines that the character is unusable (i.e. no more unique alphanumeric strings can be generated with this first character) and it does get stored in an array (if applicable). Would it be faster to check the newly generated character using the same method I have been using, or check it against what is in the array;
- If found in array (must be case-sensitive), start back all over to generate first character.
- If not found in array than use old method to check it still usable.
I hope I have explained it clearly enough, if not feel free to let me know.
Edit: I should also mention that I have no experience using arrays. Wanted to first find out if it is appropriate to use an array.
Say I am generating a 4 character alphanumeric string.
The code loops and generates the first character, checks if it can create any more passwords with that character.
If it can, it stores this character, it continues the loop to generate the second alphanumeric character.
If it can’t, it starts all over again at the first character.
What I would like to do is to somehow store the character(s) that the code determines is unusable as opposed to doing running through the code again. How would I accomplish that? Store it in an array?
Right now the way I am accomplishing that is to have it look at the strinig in the table with the right length of characters. If it is generating the first character, then count the number of records that have the start with the same character (or characters) that is generated (matching upper or lower case as well) and then count the number of records it finds and see if it is less than the total possible alphanumeric strings that begin with the generated first character (or first two characters if we are on the second character of the stringand so on)
Say at the point the code determines that the character is unusable (i.e. no more unique alphanumeric strings can be generated with this first character) and it does get stored in an array (if applicable). Would it be faster to check the newly generated character using the same method I have been using, or check it against what is in the array;
- If found in array (must be case-sensitive), start back all over to generate first character.
- If not found in array than use old method to check it still usable.
I hope I have explained it clearly enough, if not feel free to let me know.
Edit: I should also mention that I have no experience using arrays. Wanted to first find out if it is appropriate to use an array.
Last edited: