Location: PHPKode > scripts > PHP Hash Generator > php-hash-generator/hash.php
<?
/*========================================================================*\
|| ###################################################################### ||
|| # ---------- Hash Generator Script - Keith Armstrong --------------- # ||
|| # ----------------VERSION: 1.1.2 | 2:07 PM 3/20/2010---------------- # ||
|| # This file may be distributed as long as the Author is given credit # ||
|| # ----- http://www.hotscripts.com/listing/php-hash-generator/ ------ # ||
|| # Note: This script was made by a 16 year old and isn't professional # ||
|| ###################################################################### ||
\*========================================================================*/

// String inputted to be encrypted
	$value = $_POST['string'];
// Encryption type
	$type = $_POST["type"];
// The output of an empty MD5 hash or a value of null, automatically makes the md5 option selected
	if ($output == "d41d8cd98f00b204e9800998ecf8427e" || $value == "") {
		$output = "";
		$md5s = "selected='selected'";
	}
// If user chooses MD5 and value isn't null, then it will encrypt with MD5
	if ($type == "MD5" && $value != "") { 
		$output = md5($value);
		$md5s = "selected='selected'";
		$type = "MD5 (128-bit encryption): ";
            }
// If user chooses MD4 and value isn't null, then it will encrypt with MD4
        else if ($type == "MD4" && $value != "") {
        	$output = bin2hex(mhash(MHASH_MD4,$value));
        	$md4s = "selected='selected'";
        	$type = "MD4 (128-bit encryption): ";
	    }
// If user chooses SHA-1 and value isn't null, then it will encrypt with SHA-1
	else if ($type == "SHA-1" && $value != "") {
		$output = sha1($value);
		$sha1s = "selected='selected'";
		$type = "SHA-1 (160-bit encryption): ";
	    }
// If user chooses SHA-2 and value isn't null, then it will encrypt with SHA-2
	else if ($type == "SHA-2 (256)" && $value != "") {
		$output = hash('sha256', $value);
		$sha2s = "selected='selected'";
		$type = "SHA-2 (256) (256-bit encryption): ";
	    }
// If user chooses BASE64 and value isn't null, then it will encrypt with BASE64
	else if ($type == "BASE64" && $value != "") {
		$output = base64_encode($value);
		$base64s = "selected='selected'";
		$type = "BASE-64 (6-bit encryption): ";
	    }
// If user chooses ALL and value isn't null, then it will encrypt with ALL of the encryption methods
	else if ($type == "all" && $value != "") {
		$output = md5($value);
		$output2 = bin2hex(mhash(MHASH_MD4,$value));
		$output3 = sha1($value);
		$output4 = hash('sha256', $value);
		$output5 = base64_encode($value);		
		$alls = "selected='selected'";
		$type = "MD5 (128-bit encryption): ";
		$type2 = "MD4 (128-bit encryption): ";
		$type3 = "SHA-1 (160-bit encryption): ";
		$type4 = "SHA-2 (256) (256-bit encryption): ";
		$type5 = "BASE-64 (6-bit encryption): ";
	    }
?>
<html>
<head>
<title>Hashed Text Generator</title>
</head>
<body bgcolor="black" text="white">
<div align="center"><h1>Hashed Text Generator</h1></div>
<hr>
<center><form action="<? $_SERVER['PHP_SELF'] ?>" method="POST">
<br>
Enter String to be hashed: <input type="text" name="string" value="<? echo $value ?>"><br>Select Hash Algorithm: <select style="width: 250px;" id="type" name="type">
<option <? echo $md5s ?> value="MD5">MD5 (128-bit encryption)</option>
<option <? echo $md4s ?> value="MD4">MD4 (128-bit encryption)</option>
<option <? echo $sha1s ?> value="SHA-1">SHA-1 (160-bit encryption)</option>
<option <? echo $sha2s ?> value="SHA-2 (256)">SHA-2 (256) (256-bit encryption)</option>
<option <? echo $base64s ?> value="BASE64">BASE-64 (6-bit encryption)</option>
<option <? echo $alls ?> value="all">ALL ENCRYPTIONS</option>
</select>
<br>
<br>
<input type="submit" value="Generate">&nbsp;<input type="button" onclick='window.location.href="<? $_SERVER['PHP_SELF'] ?>"' value="Reset">
</form>
<br>
<hr>
<center>OUTPUT</center>
<br>
<center>
<?
// If no value is entered, it will not display the MD5:, MD4:, etc.
if($value == "") {
		$type = "";
		$type2 = "";
		$type3 = "";
		$type4 = "";
		$type5 = "";
}
?>
<h2><font color="red"><? echo $type ?></font><font color="limegreen"><? echo $output ?></font></h2>
<h2><font color="red"><? echo $type2 ?></font><font color="orange"><? echo $output2 ?></font></h2>
<h2><font color="red"><? echo $type3 ?></font><font color="purple"><? echo $output3 ?></font></h2>
<h2><font color="red"><? echo $type4 ?></font><font color="blue"><? echo $output4 ?></font></h2>
<h2><font color="red"><? echo $type5 ?></font><font color="yellow"><? echo $output5 ?></font></h2>
</center>
<!-- This script was downloaded from http://www.hotscripts.com/listing/php-hash-generator/ -->
<body>
</html>
Return current item: PHP Hash Generator