fisrt task given: hashing the url using combination of sha-1 and md5 algorithm....
sha-1 and md5 hashing.php
<?php
if (isset($_POST['URL'])) {
//Start MD5 Hash Generator\\
$pass2=$_POST['URL'];
$URL=md5($pass2);
if($_POST['URL'] != NULL)
$pass3=sha1($URL); }
else
$pass3= "";
$dbhost = 'localhost';
$dbuser = 'root';
$conn = mysql_connect($dbhost, $dbuser);
if(! $conn ) {
{
die('Could not connect: ' . mysql_error());
}
if(! get_magic_quotes_gpc() )
{
$url_name = addslashes ($_POST['URL']);
$hash_value = addslashes ($_POST['hash']);
}
else
{
$url_name = $_POST['URL'];
$hash_value= $_POST['hash'];
}
$sql = "INSERT INTO urldata ".
"(url_name,hash_value) ".
"VALUES ".
"('$url_name','$hash_value')";
mysql_select_db('url');
$retval = mysql_query( $sql, $conn );
if(! $retval )
{
die('Could not enter data: ' . mysql_error());
}
echo "Entered data successfully!\n";
mysql_close($conn);
}
?>
<html>
<head><title>Cyber-MyCert </title>
</head>
<center><body><h3> Hashing The URL'S </h3></center>
<?php include ("md5.php"); ?>
<center> <form action = 'hashing md5 and sha1.php' name='gen' method= 'post'>
URL'S: <br><input type='text' size='30' maxlength='50' name='URL'> <br/>
HASH VALUE : <br><input type='text' size='50' maxlength='80'name="hash" value= "<?php echo $pass3;?>"> <br/></center>
<br><div align="center"><input type="submit" value="Hash Me"/></div></br>
<div align="center"><input type="reset" value="Back"/></div>
<center>
ENTER HASH VALUE : <br><input type='text' size='50' maxlength='80' name='hashme' > <br/>
<input type ="submit" name ="verify1" value = "verify">
</form></center>
<?php
if(isset($_POST['verify1']))
{
$npass= ($_POST['hashme']);
//$hash_me=$_POST["hashme"];
//$hash_1=$_POST["hash"];
//if (strcmp($hash_me,$hash_1)=0{
//{ print "same <br>"};
//else {print "not same <br>"};
//}
if ($npass == $_POST["hash"])
{
echo "The hash match";
}
else //($npass != isset($_POST["hash"]))
//if ($npass != isset($_POST["hash"]))
{
echo "The hash do not match";
}
}
?>
</html>
md5.php
<html>
<head>
</head>
<body>
<center>
<div align="center">
<tr><?php
echo " MD5 (Message-Digest algorithm 5) is a widely used cryptographic hash function with a 128-bit hash value.
An MD5 hash is typically expressed as a 32-digit hexadecimal number.While, SHA-1 produces a 160-bit message digest"
?> <tr/>
</div>
</center>
</html>
1 comments:
koding yg x seberapa nie..ak mek mase 2 mggu nak ciapkan...haha
Post a Comment