This class in PHP can be used as a simple method of authentication. It uses the MD5 of a string as secret and can be easily bookmarked. It doesn't uses cookies, session or login/password combo, just a single secret passed by URL.
Example: http://example.org/file.php?key=7315a012ecad1059a3634f8be1347846
In this case, 7315a012ecad1059a3634f8be1347846
is the MD5 of my password: "MySecretPassword"
.
Source Code
All source code is online here.
How to use it
<?php
require_once('SimpleAuth.class.php');
$simpleAuth = new SimpleAuth('MySecretPassword');
/**
* Valid URLs:
* http://example.org/file.php?key=7315a012ecad1059a3634f8be1347846
* http://example.org/file.php?key=MySecretPassword
*/
if ($simpleAuth->isValid()) {
// Secure Zone
} else {
// Wrong Password
}
/**
* Show MD5 key, valid URL:
* http://example.org/file.php?key=MySecretPassword&help
*/
if ($simpleAuth->isValid() && isset($_GET['help'])) {
echo $simpleAuth->getSecret(); // Show MD5 key
}
?>