note 38038 added to function.base64-decode

From: Date: Fri, 05 Dec 2003 16:34:05 +0000
Subject: note 38038 added to function.base64-decode
Groups: php.notes 
Request: Send a blank email to php-notes+get-61456@lists.php.net to get a copy of this message
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"; } ?> ---- Manual Page -- http://www.php.net/manual/en/function.base64-decode.php Edit -- http://master.php.net/manage/user-notes.php?action=edit+38038 Delete -- http://master.php.net/manage/user-notes.php?action=delete+38038&report=yes Reject -- http://master.php.net/manage/user-notes.php?action=reject+38038&report=yes Search -- http://master.php.net/manage/user-notes.php

« previous php.notes (#61456) next »