mardi 14 avril 2015

PHP | Unique code generation

I have a query related to generating unique series of characters with PHP.


Assume that I want to create a web app which generates coupon/voucher codes for my business/application.


I would need the code to contain only alphabetic letters and numbers (no numbers) and heres the crucial part; the algorithm behind the generation needs to be secure. So no silly old algorithm where a user can crack the algorithm in 2 mins.


I am aware people can brute force codes regardless, but we should start by using a secure function to generate them.


Is there built in functions already? Should I use just those functions or can/should I take it a step further and do something else?


All help is appreciated, At the moment in my research and experiments I found the uniqid() function and rand() function, but PHP explicitly tells you that they are "predictable" and should not be used where security is a concern.





Aucun commentaire:

Enregistrer un commentaire