24 Des 2011

How to make an ecrypted login page (basic) "cara membuat login yang ter enkripsi"

Okay, today i'll show you some of my task, where i have to make a "login", okay, just see this i hope you can understand what i'm talking about :D
first : make a page for the form, named it with "index.html"
index.html functions to enter the username and password, which will be stored in the variable $ username for the username and passworrd for input will be stored in the variable $ password, and here is the script for "index.html"

<html>
<head>
<title>Encryption in PHP</title>
</head>
<body>
<form id="form1" name="form1" method="post" action="Passwordconfirmation.php">
<table width="200" border="1">
<tr>
<td colspan="2"><center>Login</center></td>
</tr>

<tr>
<td>Username</td>
<td>
<input type="text" name="username" /></td>
</tr>
<tr>
<td>password</td>
<td>
<input type="password" name="password" /></td>
</tr>
<tr>
<td>&nbsp;</td>
<td>
<input type="submit" name="Submit" value="Submit" /></td>
</tr>
</table>
</form>

</body>
</html>

Okay, as you can see, we need "Passwordconfirmation.php" page function to confirm whether password and username entered is and1 and encryption for the her, if the same or the correct for the input the password and username then it will go to encryption.php page but if one then will display the words "Your username or password is wrong".
and here the script :
<?
if (isset($password) and isset($username) )
{
$validasipwd = crc32("and1"); /*cr32 you can change with md5 or crypt */
$validasiusr = ("and1");

$pwd = crc32($password);
$usr = $username;
if (($validasipwd == $pwd) and ($validasiusr == $usr))
{
include "enkripsi.php";
}
else
{
print("<b>Your username or password is wrong<br>");
}
}
?>

Encryption.php function to encrypt password into some form of encryption, and here the script :
<html>
<head>
<style>
small{
color:blue;
font-size:20px;
}
</style>

<title>Encryption in PHP</title>
</head><body>
<?php
echo "for password: $password<br>";
$md5=md5($password);
$md5true=md5($password,true);

$sha1=sha1($password);
$sha1true=sha1($password,true);

$salt="cruzenaldo";
$crypt=crypt($password);
$cryptsalt=crypt($password, $salt);
$base64e=base64_encode($password);
$base64d=base64_decode($password);

echo "<strong>using md5() raw_output false :</strong> <small>$md5</small><br>";
echo "<strong>using md5() raw_output true :</strong> <small>$md5true</small><br>";

echo "<strong>use sha1() raw_output false :</strong> <small>$sha1</small><br>";
echo "<strong>use sha1() raw_output true :</strong> <small>$sha1true</small><br>";

echo "<strong>use crypt without salt (it will always change when refreshed) :</strong> <small>$crypt</small><br>";
?>
</body>
</html>


Okay :D that's all have a nice try buddy :D

Tidak ada komentar:

Posting Komentar