We’re handing out “screeners” at Sundance. One-day free memberships to our streaming movie site. To do this we’d have to give people a “promo code” which will get them the free membership when they come to the site to sign up. To prevent people from just reupping every 24 hours, each code can only be used once. And to make it harder for people to guess other codes, they’ll have to be randomly generated alphanumeric codes.
What’s the best way to generate say a thousand of these?
Thanks in advance.
There are countless password generators that run in Excel out there. What I’d envision doing is to fire one up to create 1,000 passwords. You can then do a mail-merge type operation to insert one password from the Excel results into Word and print the fliers.
When people come back with these codes, your system can run a quick lookup on the list of passwords to see if it’s valid or not.
Just use a good pseudo-random number generator to create a list of however many codes you need. If you use a 64 bit data space, that gives you 1.8 e19 possible numbers. Even if you needed a million codes, the chance of anyone guessing a correct code is 1 in a quadrillion. If you use 0-9, A-Z to represent your number, it’s a 12 character code (which isn’t so bad). You can shorten the code by quite a bit and still make the chance of guessing a correct code vanishingly small.
Here is one of many different ways to do it in ruby:
1000.times {
puts rand("ZZZZZZZZZZZZ".to_i(36)).to_s(36).upcase.rjust(12, '0')
}
This will generate 1000 twelve-character codes, padded on the left with zeroes when necessary.