![]() ![]() I can shuffle my alphabet and my positions so that instead of The user who buys voucher "AAAAAAAAAY" should not have a good chance of getting another valid code if they type in "AAAAAAAAAZ". I do not want guessable voucher codes though. So this leaves me with using the codes sequentially. But this means I have to store many codes, and in fact my keyspace is bigger than the one i described, so we're talking about a very large amount of data. I could pre-generate all codes and shuffle them, then consume them in order. At the extreme when there is only one code left it will be nearly impossible for the system to guess it correctly. As the system accumulates more data it will slow down. This obviously has a big problem though - I have to check my random number against all previously generated voucher codes and if it collides with an existing one I'll have to discard the code and try another. My first approach is to number all possible codes from 0 to 308,915,776, then start generating random numbers in that range. What is the correct algorithm to do this?! Let's assume I adopt some code format - say 10 characters from A to Z for simplicity, and I start generating vouchers. Now that I'm into implementation I realize I've got another problem altogether, more of an algorithmic challenge. I wanted to find the best tradeoff between large keyspace, low guessability, and human readability. ![]() I recently posted this question about codes for a gift-card-like voucher that users can redeem online. ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |