Created
June 6, 2012 18:06
-
-
Save liv3d/2883651 to your computer and use it in GitHub Desktop.
Basic PHP script to encode various encryptions
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| /* | |
| * | |
| * Encode text to sha1/md5/base64 | |
| * | |
| */ | |
| $have_output = 0; | |
| if( isset ( $_POST['Submitter'] ) ) | |
| { | |
| if ( $_POST['Submitter'] == "Submit" ) | |
| { | |
| if( ! isset ( $_POST['text'] )) | |
| { | |
| die("Error no text set"); | |
| } | |
| if( ! isset ( $_POST['hash'] )) | |
| { | |
| var_dump($_POST); | |
| die("Error no hash set"); | |
| } | |
| $postText = $_POST['text']; | |
| $postHash = $_POST['hash']; | |
| switch ($postHash) | |
| { | |
| case "md5": | |
| $output = md5 ( $postText ); | |
| $have_output = 1; | |
| break; | |
| case "sha1": | |
| $output = sha1 ( $postText ); | |
| $have_output = 1; | |
| break; | |
| case "base64": | |
| $output = base64_encode ( $postText ); | |
| $have_output = 1; | |
| break; | |
| default: | |
| die ( "Error: no input selected" ); | |
| } | |
| } | |
| } | |
| ?> | |
| <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> | |
| <html xmlns="http://www.w3.org/1999/xhtml"> | |
| <head> | |
| <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> | |
| <meta http-equiv="Pragma" content="no-cache" /> | |
| <meta http-equiv="Expires" content="-1" /> | |
| <title>md5/sha1/base64 Encoder</title> | |
| <style type="text/css"> | |
| body | |
| { | |
| background:#fffff; | |
| font-family:"Lucida Grande", Tahoma, Arial, Verdana, sans-serif; | |
| font-size:small; | |
| margin:8px 0 16px; | |
| text-align:center; | |
| } | |
| </style> | |
| </head> | |
| <body> | |
| <?php | |
| if ( $have_output == 1 ) | |
| { | |
| ?> | |
| <p><span style="color:Red">Encoded Data: <?php echo $output; ?> | |
| </p><p></p> | |
| <?php | |
| } | |
| ?> | |
| <form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post"> | |
| Text to encode: <input type="password" maxlength="255" name="text" value=""/> <br /> | |
| Type: <select name="hash"> | |
| <option value="sha1" selected="selected">SHA1</option> | |
| <option value="md5">MD5</option> | |
| <option value="base64">Base64</option> | |
| </select> | |
| <br /> | |
| <input type="submit" name="Submitter" value="Submit" /> | |
| </form> | |
| <pre>There is no data logged from this page. Source code is @ <a href="https://gist.github.com/2883651" target="_blank">https://gist.github.com/2883651</a></pre> | |
| <pre>Created by liv3d</pre> | |
| </body> | |
| </html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment