

- Mediaget voucher code generator how to#
- Mediaget voucher code generator generator#
- Mediaget voucher code generator verification#
- Mediaget voucher code generator free#
Let's take for example 8 characters long alphanumeric strings:Īlphanumeric = 0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ. The key to create unguessable coupon codes is a large space of possible codes with only a small fraction of them being actually valid.
Mediaget voucher code generator free#
In cryptography circles that would be very bad (this code is insecure against a fast local attack), but for a web form offering free burritos to registered users, and where you would notice a someone trying four million times with a script, it is ok. There are 20**12 valid codes in this format, which means you can issue a billion of your own codes, and there would be one in four million chance of a user simply guessing a correct one. Short_code = long_code + '-' + long_code + '-' + long_code # Convert Ruby base 20 to better characters for user experience reverse ensures we don't use first character (which may not take all values) rjust(12, '0') covers for unlikely, but possible small numbers Putting that all together, this is how I might generate a usable code: # Random, unguessable number as a base20 string

This isn't usually a concern because users do not see most computer secure codes, but these ones will be in print! If your code contained only the characters K, U, F, C, then there would be a high chance of offending a user. Here's an interesting one - you may want to scan the code for possible rude words, or avoid the characters that would generate them. I would suggest 12 characters, in 3 groups of 4.

In print, separate the code into a few small parts, it will be easier for the user to find their place in the string and type a few characters at once.ĭon't make the code too long. This is best done by processing the input text so it is in the right case, strip separator characters etc. Perhaps even allow 0 and O to mean the same thing. Case sensitivity will not be understood or followed by some %age of your users.Īccept variations when matching codes. Use either lower case or upper case letters but not both. It would be a bad user experience to have to try several variations of a code by testing 0 vs O, 5 vs S etc. We often understand what it is supposed to be from context, but a randomised string of characters does not have this context. In print, it is sometimes difficult to see the difference between 1, I and l for example. I cannot answer that for you, but can make some general points about usability:Īvoid ambiguous characters. You need to bear in mind the value to the end user, and therefore how hard someone might try to get a valid code.

Mediaget voucher code generator how to#
Once you know how to generate a random, practically unguessable code, your next problem is understanding user experience and deciding how much you can realistically compromise security in the name of usability. However, it is a bit awkward to type from a physical copy. This code is long enough to cover any realistic number of vouchers (millions each for everyone on the planet), without any meaningful chance of repetition or being easy to guess. Ruby has the securerandom library, which you can use to get a raw code like this: require 'securerandom' The starting point for such a secure code would be the output from a cryptographic PRNG.
Mediaget voucher code generator generator#
More sophisticated users might spot that your "random" codes use a hackable random number generator (Ruby's default rand() is fast and statistically good for random data, but is hackable in this way, so don't use it). This is necessary to avoid users figuring out that most valid codes start with "AAA" for example. It also means that the codes that you use must be chosen as randomly as possible within all possible codes. This sounds high, but is possible in relatively short strings. Depending on how easy it is to simply try codes (think of a script trying repeatedly), then you might need all possible codes to outnumber issued codes by a factor of a million or a billion or more. That means the number of all possible codes in that format is much larger than the number of codes you want to issue.
Mediaget voucher code generator verification#
The code needs to be unguessable, because the only verification you can perform before giving the user their reward is to check whether the code they entered exists in your list of "issued" codes.
