sangoku Posted February 22, 2010 Share Posted February 22, 2010 Hy i need a secure code which i need to send to a users mail for confirmation of the mail. can someone toss me a good one looked over the net but dint find anything that i liked. Quote Link to comment https://forums.phpfreaks.com/topic/192973-some-secure-random-generator-anyone/ Share on other sites More sharing options...
ialsoagree Posted February 22, 2010 Share Posted February 22, 2010 If uniqueness is not necessary, you can use a function like md5 or sha1 to hash a random value like the current milliseconds or a number generated with rand. Quote Link to comment https://forums.phpfreaks.com/topic/192973-some-secure-random-generator-anyone/#findComment-1016284 Share on other sites More sharing options...
sangoku Posted February 22, 2010 Author Share Posted February 22, 2010 Uniqueness is required.. i need it to be unique.... any toth how to make it? I already read about sha and md gen with timestamp but that is not unique... Quote Link to comment https://forums.phpfreaks.com/topic/192973-some-secure-random-generator-anyone/#findComment-1016285 Share on other sites More sharing options...
ialsoagree Posted February 22, 2010 Share Posted February 22, 2010 There's a few approaches to this. Primarily your goal is to take a unique value and turn it into a unique gibberish string. It depends on the needs of your project, but one approach would be use an incrementing value (increments after a unique code is generated) and then encrypt the value using a reversible encryption such as mcrypt_generic(). The incremented value will never be the same (it will always be greater than any previous value) and thus the encryption will never be the same. The encryption will make it much more difficult to determine what value is being used (and thus, to predict the next value that will be used and it's resulting key). Quote Link to comment https://forums.phpfreaks.com/topic/192973-some-secure-random-generator-anyone/#findComment-1016289 Share on other sites More sharing options...
sangoku Posted February 22, 2010 Author Share Posted February 22, 2010 That is what im talking about $ha = 1 while ($ha>0){ Thank you! } I dont care that is a loop Quote Link to comment https://forums.phpfreaks.com/topic/192973-some-secure-random-generator-anyone/#findComment-1016290 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.