# Format Preserving Encryption - Generating coupon codes

If I use cycle FPE with AES to generate 20 digit coupon codes, what is the probability that an attacker could generate a valid coupon?

## 1 Answer

That depends on what coupon codes are accepted rather than the details of the FPE. FPE is a pseudo-random permutation that depends on the key. If the attacker inserts any encrypted coupon code in the specified domain (in this case 20 digits) then it will with certainty result in a 20 digit coupon code after decryption.

So what chance is there that the coupon code is accepted? Well, it is exactly the same as a normal coupon code. If the coupon allows any 20 digit code then the likelihood of it being accepted is of course precisely one. Commonly though a coupon code also contains a method of verification. Then it depends on the verification method what chance there is of a random coupon code to be accepted.

Say there is one decimal check digit and a calculation that results in a uniform distribution given random input of the other digits. In that case the chances of generating a probability of generating a valid coupon code is of course one in ten.