language agnostic - Create a set of "coupon codes" based on an algorithm; no need to store the codes -


i have situation print out runs of "discount cards" unique code printed on card user can redeem on online store discount.

we create many of these cards, few of them being used, i'd use form of way identify valid code using method rather storing each individual code in database. create 5,000 of these codes @ time. 5 times year.

ideally i'd able like:

$coupons->generate(5000, 'unique_salt', 'prefix_'); 

which generate 5,000 "random" codes like:

prefix-23-3424-4324-3344 or prefix-4h-34re-22k3-pe3w 

the unique salt , prefix_ saved database. these codes able verified using prefix_ lookup salt , identify code valid or not.

i have form of working using number salt, find numbers divisible salt, , reorder digits appears random. long enough codes, take work figure out pattern. i'd think there's better way... there's many numbers yield large amounts of codes divisible salt.

(for example, salt of 2 yield 5,000 codes between 1 , 10,000 (and easy see pattern)... salt of 14000 yield 0 codes between 1 , 10,000)

the other advantage can generate coupons needed (such when give individuals discount on 1 one basis), , able track coupons used when, etc based on prefix_... , potentially see how/when cards passed out, yields best return.

am spinning wheels when should storing each code in database? (or having fun?) :)

what looking called partial key verification serial numbers on software cds :)

have at:

http://47hats.com/2007/07/implementing-a-partial-serial-number-verification-system/

http://www.codeproject.com/kb/security/cdkeys.aspx

http://www.brandonstaggs.com/2007/07/26/implementing-a-partial-serial-number-verification-system-in-delphi/

cheers


Comments

Popular posts from this blog

c# - how to write client side events functions for the combobox items -

exception - Python, pyPdf OCR error: pyPdf.utils.PdfReadError: EOF marker not found -