j.smith1981 Posted November 3, 2010 Share Posted November 3, 2010 I have a weird problem with an md5() function. I am trying to write a token system, (just for my own fun really), going off an example guestbook I got help with from here. What my main aim is to allow the moderator for the guestbook to receive an email (which is working in its own context), with a link to a script page that checks into the database and when the user clicks on the link it allows the message in the guestbook to be shown. But when I try md5() the ip address of the user it works, but I thought if that same user went in and did another post, it would come up with the same checksum, causing quite bad problems to be honest. So I thought about using something like: $time = microtime(); $checksum = md5($ip,$time); But this keeps coming up with say: 3RiYD Is there anyway of getting around this at all? To show a real value as I am sure this wont work, any helps greatly appreciated, Jeremy Quote Link to comment https://forums.phpfreaks.com/topic/217643-md5-keeps-bringing-up-weird-characters-when-i-add-a-2nd-arguement-to-it/ Share on other sites More sharing options...
MasterACE14 Posted November 3, 2010 Share Posted November 3, 2010 the second argument can only be true or false, are you trying to join $ip with $time? in which case you would do the following: $time = microtime(); $checksum = md5($ip.$time); using a period, rather than a comma. Quote Link to comment https://forums.phpfreaks.com/topic/217643-md5-keeps-bringing-up-weird-characters-when-i-add-a-2nd-arguement-to-it/#findComment-1129851 Share on other sites More sharing options...
Airzooka Posted November 3, 2010 Share Posted November 3, 2010 Additionally, are you sure the second argument is what you think it is? If the second argument is TRUE, the md5 digest is returned in a raw binary format. Quote Link to comment https://forums.phpfreaks.com/topic/217643-md5-keeps-bringing-up-weird-characters-when-i-add-a-2nd-arguement-to-it/#findComment-1129854 Share on other sites More sharing options...
j.smith1981 Posted November 3, 2010 Author Share Posted November 3, 2010 the second argument can only be true or false, are you trying to join $ip with $time? in which case you would do the following: $time = microtime(); $checksum = md5($ip.$time); using a period, rather than a comma. Additionally, are you sure the second argument is what you think it is? If the second argument is TRUE, the md5 digest is returned in a raw binary format. Ahh ok, I was treating it like any other custom function I have done where you go: function myFunction($var1,$var2) { // do whatever with $var1 . $var2; } $value1 = 'my first value'; $value2 = 'my second value'; myFunction($value1,$value2) // < thinking this is how you do the md5() function God I should have previously gone through a tutorial before I found on here and put that into mine, ace thanks ever so much for your help, will see what the output of TRUE is though and see what happens. What I have got allot into recently, is criticising my own methods for doing things, already learning allot about the more theoretical parts of application design, I am loving it though! Going to move this onto a complete auth system for myself and use various free security apps to see if I can break them deliberately to see if I can bump their security up a notch (something I have been dabbling with at work regarding PCI Compliance). But thats wonderful thank you soo much, Jeremy. Quote Link to comment https://forums.phpfreaks.com/topic/217643-md5-keeps-bringing-up-weird-characters-when-i-add-a-2nd-arguement-to-it/#findComment-1129855 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.