1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49
|
<!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" />
<title>Cyptage avec clé.</title>
<style type="text/css">
<!--
-->
</style>
</head>
<body>
<fieldset>
<legend><u><strong>Script de cryptage*</strong></u></legend>
<?
if (isset ($_POST['cle_de_cryptage']) && isset ($_POST['information_a_crypter']))
{$cle_de_cryptage = $_POST['cle_de_cryptage'];
$information_a_crypte = $_POST['information_a_crypter'];
$algo = MCRYPT_BLOWFISH;
$mode = MCRYPT_MODE_NOFB;
$key_size = mcrypt_module_get_algo_key_size($algo);
$iv_size = mcrypt_get_iv_size($algo, $mode);
$iv = mcrypt_create_iv($iv_size, substr("Exemple par",0,$iv_size));
$cle_de_cryptage = substr($cle_de_cryptage, 0, $key_size);
$information_crypte = mcrypt_encrypt($algo, $cle_de_cryptage, $information_a_crypte, $mode, $iv);
$information_decrypte = mcrypt_decrypt($algo, $cle_de_cryptage, $information_crypte, $mode, $iv);
echo ('Informations à crypter = "'.$information_a_crypte.'"<br> Informations crypter = "'.$information_crypte.'"<br> Information décrypter = "'.$information_decrypte.'"');
unset ($_POST['cle_cryptage'], $_POST['information_a_crypter']);}
else {
?>
<form method="post">
<ul>
<li><u>Clé de cryptage :</u></li>
<input name="cle_de_cryptage" type="text" size="100" maxlength="100" />
<li><u>Information à crypté :</u></li>
<textarea name="information_a_crypter" cols="100" rows="10" wrap="physical"></textarea>
</ul>
<input type="submit" value="Crypter">
<input name="" type="reset">
</form>
<?
;}
?>
(* = "Décryptage possible avec la clé")
</fieldset>
</body>
</html> |
Partager