I have the following code that creates a security hash for authentication on media servers, I would like to know how it could be validated in php itself, media servers should use some logic for this , and that's what I want, a code that does the same thing in php.
I think the biggest difficulty is with gmdate
that changes the face access to the hash generation function, such as hash is passed via md5
, you can not get gmdate
for a comparison, for security of course, so what could be done to create a new hash wmsAuthSign
validation function? >
The wmsAuthSign generation code >:
$today = gmdate("n/j/Y g:i:s A");
$ip = $_SERVER['REMOTE_ADDR'];
$key = "defaultpassword";
$validminutes = 20;
$str2hash = $ip . $key . $today . $validminutes;
$md5raw = md5($str2hash, true);
$base64hash = base64_encode($md5raw);
$urlsignature = "server_time=" . $today ."&hash_value=" . $base64hash. "&validminutes=$validminutes";
$base64urlsignature = base64_encode($urlsignature);
wmsAuthSign=<?php echo $base64urlsignature;?>
In summary, I create my own hash , but I do not know how to validate it in php.