<!DOCTYPE html>
<html>
<head>
	<title>Connexion</title>
	<meta charset="utf-8">
</head>
<body>

<p>Mon mot de passe avant cryptage : <?php echo $_POST['pass']; ?></p>

<?php
// Sources www.stackoverflow.com

function encrypt($pure_string, $encryption_key) {
    $iv_size = mcrypt_get_iv_size(MCRYPT_BLOWFISH, MCRYPT_MODE_ECB);
    $iv = mcrypt_create_iv($iv_size, MCRYPT_RAND);
    $encrypted_string = mcrypt_encrypt(MCRYPT_BLOWFISH, $encryption_key, utf8_encode($pure_string), MCRYPT_MODE_ECB, $iv);
    return $encrypted_string;
}

function decrypt($encrypted_string, $encryption_key) {
    $iv_size = mcrypt_get_iv_size(MCRYPT_BLOWFISH, MCRYPT_MODE_ECB);
    $iv = mcrypt_create_iv($iv_size, MCRYPT_RAND);
    $decrypted_string = mcrypt_decrypt(MCRYPT_BLOWFISH, $encryption_key, $encrypted_string, MCRYPT_MODE_ECB, $iv);
    return $decrypted_string;
}

$pseudo = $_POST['pseudo'];
$messageAChiffrer = $_POST['pass'];
$cleSecrete = "GsbAIleDeMort";


// On chiffre le message
$motdepasse = encrypt($messageAChiffrer, $cleSecrete);
echo "bonjour ".$pseudo;

if (isset($motdepasse) AND $motdepasse ==  "kangourou") {
	echo "le mot de passe a t rentr et est bueno !"
} else {
	echo "Mot de passe incorrect !"
}

?><br/>


</body>
</html>