My first idea was to make an array/list that has values assigned to each character. So for example:
array[0] =' 0'
array[10] = 'A'
[...]
Then code would pick a random number y between [0,x] for slot 1. For next slot [0,(x-y)] etc. When y <= 0 then fill rest of the slots with '0'.
Would that be enough for a simple voucher code generator? (It's not my decision to make encryption with this rule)
I am worried that sum of 9 is quite low for 6 character code, letters won't be used at all since they all have value over 9. To prevent situation like this: 540000, 630000, 180000 Should I make chance of '0' to appear more?
What do you guys think about it? Maybe you could also suggest some other way of doing this.
Aucun commentaire:
Enregistrer un commentaire