note 71821 added to function.md5

From: Date: Mon, 18 Dec 2006 04:03:39 +0000
Subject: note 71821 added to function.md5
Groups: php.notes 
Request: Send a blank email to php-notes+get-120716@lists.php.net to get a copy of this message
I was looking for a simple way to secure a script from abuse when the idea of signing the get request hit me... <?PHP $text = $_GET["text"]; $key = "MyExampleSignKey"; if (md5($text . $key) != $_GET['md5']) die("Unauthorized Use"); echo "Authorized Use :D"; ?> This means that parameters can be passed with a signature of the value and the hidden key. I wanted this for a small image generation script that could be put into a <img src=""> tag. It could also be useful for simple protection from malicious urls since the client doesnt know the key to hash the data with and the script will fail on modification. <?PHP $page = $_GET["include"]; $key = "MyExampleSignKey"; if (md5($text . $key) != $_GET['md5']) die("Unauthorized Use"); include($page); ?> A small function could help in production of links... <?PHP function signedURL($key, $page, $link) { return "<a href=\"index.php?page=$page\">$link</a>"; } ?> ---- Server IP: 203.16.234.20 Probable Submitter: 165.12.252.11 (proxied: unknown) ---- Manual Page -- http://www.php.net/manual/en/function.md5.php Edit -- https://master.php.net/note/edit/71821 Del: integrated -- https://master.php.net/note/delete/71821/integrated Del: useless -- https://master.php.net/note/delete/71821/useless Del: bad code -- https://master.php.net/note/delete/71821/bad+code Del: spam -- https://master.php.net/note/delete/71821/spam Del: non-english -- https://master.php.net/note/delete/71821/non-english Del: in docs -- https://master.php.net/note/delete/71821/in+docs Del: other reasons-- https://master.php.net/note/delete/71821 Reject -- https://master.php.net/note/reject/71821 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#120716) next »