Jump to content

md5() keeps bringing up weird characters when I add a 2nd arguement to it


j.smith1981

Recommended Posts

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

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.

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.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.