note 38038 deleted from function.base64-decode by felipe

From: Date: Sat, 29 Mar 2008 15:33:06 +0000
Subject: note 38038 deleted from function.base64-decode by felipe
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-137706@lists.php.net to get a copy of this message
Note Submitter: dharwood at synopsistechnologies dot com ---- Encode/DEcode PAGE. Here is a page that will accept plain text password and return an encoded password. It will also do the opposite. It will allow you to enter an encoded password and generate the plain text password... (just in case you forgot your password.) <?php if (isset($_POST['text_pass'])){ $but=$_POST['button']; process_form(); }else{ print_form(); } function process_form(){ switch ($_POST['button']){ case "Get Encoded": $text_pass = $_REQUEST['text_pass']; echo "<html>\n"; echo "<head>\n"; echo "<title>Password Encoding</title>\n"; echo "<meta http-equiv=\"Content-Type\" content=\"text/html; charset=iso-8859-1\">\n"; echo "</head>\n"; echo "<body>\n"; echo "<table border=\"0\" cellspacing=\"0\" cellpadding=\"4\" width=\"100%\">\n"; echo "<div align=\"center\">\n"; echo "<h3 align=center>Password Encoding Page</h3>\n"; echo "<table align=\"center\" border=\"0\">\n"; echo "<tr>\n"; echo "<td ><b>You Entered: </b></td>\n"; echo "<td>$text_pass</td>\n"; echo "</tr>\n"; $test = base64_encode(serialize($text_pass)); echo "<tr>\n"; echo "<td ><b>Your encoded password (base 64) is: </b></td>\n"; echo "<td>$test</td>\n"; echo "</tr>\n"; $untest = unserialize(base64_decode($test)); echo "<tr>\n"; echo "<td ><b>To double test, your UNencoded password (base 64) is: </b></td>\n"; echo "<td>$untest</td>\n"; echo "</tr>\n"; echo "</table>\n"; break; case "Get UNEncoded": $text_pass = $_REQUEST['text_pass']; echo "<html>\n"; echo "<head>\n"; echo "<title>Password Encoding</title>\n"; echo "<meta http-equiv=\"Content-Type\" content=\"text/html; charset=iso-8859-1\">\n"; echo "</head>\n"; echo "<body>\n"; echo "<table border=\"0\" cellspacing=\"0\" cellpadding=\"4\" width=\"100%\">\n"; echo "<div align=\"center\">\n"; echo "<h3 align=center>Password Encoding Page</h3>\n"; echo "<table align=\"center\" border=\"0\">\n"; echo "<tr>\n"; echo "<td ><b>You Entered: </b></td>\n"; echo "<td>$text_pass</td>\n"; echo "</tr>\n"; $untest = unserialize(base64_decode($text_pass)); echo "<tr>\n"; echo "<td ><b>Your UNencoded password (base 64) is: </b></td>\n"; echo "<td>$untest</td>\n"; echo "</tr>\n"; echo "</table>\n"; default: break; } } function print_form(){ echo "<html>\n"; echo "<head>\n"; echo "<title>Password Encoding</title>\n"; echo "<meta http-equiv=\"Content-Type\" content=\"text/html; charset=iso-8859-1\">\n"; echo "</head>\n"; echo "<body>\n"; echo "<table border=\"0\" cellspacing=\"0\" width=\"100%\">\n"; echo "<div align=\"center\">\n"; echo "<h3 align=center>Password Encoding Page</h3>\n"; echo "<tr>\n"; echo "<form action=\"$_SERVER[PHP_SELF]\" method=\"post\">\n"; echo "<table align=\"center\" border=\"0\">\n"; echo "<tr>\n"; echo "<td align=\"right\"><b>Password to Encode/Decode:</b></td>\n"; echo "<td align=\"right\">"; echo " <input type=\"text\" name=\"text_pass\" size=\"30\" >\n"; echo "</td>\n"; echo "</tr>\n"; echo "</tr>\n"; echo "<tr>\n"; echo "<tr>\n"; echo "&nbsp;\n"; echo "</tr>\n"; echo "<td >"; echo "<input type=\"submit\" name=\"button\" value=\"Get Encoded\"><br>\n"; echo "</td>"; echo "<td >"; echo "<input type=\"submit\" name=\"button\" value=\"Get UNEncoded\"><br>\n"; echo "</td>"; echo "</tr>\n"; echo "</table>\n"; echo "</form>\n"; echo "<tr>\n"; echo "</table>\n"; echo "</body>\n"; echo "</html>\n"; } ?>

« previous php.notes (#137706) next »