I am setting up a voucher code system for a checkout written in C# and I want to be able to distribute unique vouchers that do the same thing, sort of like a product key.
Is there any way of generating unique (fairly short and preferably alpha-numeric) strings that will “hash” in some way to give the same result?
In other words, can I start with a defined voucher code and get multiple results for a reverse hash?
I’m sorry if I’m not explaining this very well – I can give more information if needed.
EDIT: I know that I could use a look-up table with pre-defined codes, but I was wondering if there is a way to auto-generate these codes to allow the system to scale easily.
Here’s a thought…
Start w/ some secret password: “100:mypass:yourpass”
then md5 that: you’ll get
…
Not sure on the ‘distribution’ point on this, e.g. if it will be running on a POS type gift card or voucher card system or what, but if you notice I put 3 components into the ‘password’, this value could contain the total legitimate keys (split on “:”, resulting in a break on 100 valid keys ), a system (distributor) password, and a local system password that would be required to ‘verify’ or ‘match’ on a ‘good’ key. You could just do a quick scan to see if the key exists or not and write an invalidation routine locally. I know, my math genius friends would probably say there’s a better, more secure and effective way but hey… this is what you asked for right? I’m a simple man and like simple things… but you could make it more complicated by allowing for ranges too…
e.g.
pass=> "100:1000:pass1:pass2"that way you could test the 100->1000th md5’s partial keys…Cheers!!