Crypteur/décrypteur de texte avec mot de passe à 4 chiffres !!!

Description

Bonjour tout le monde, aujourduit, je poste un crypteur/décrypteur de texte avec un mot de passe à 4 chiffres (qui sert en fait à une clé de cryptage).

Exemple:

"Bonjour, je m'appel Thomas, j'ai 12 ans et mon pseudo est thomvaill." crypté avec le mot de passe 1225 donne:
"B°+~°^€, ~* %'`==*[ T|°%`§, ~'`{ 12 `+§ */ %°+ =§*^£° *§/ /|°%\ `{[[."
Et pour décrypter ce message, je serai obligé de mettre le mot de passe 1225, si je donne un autre mot de passe, sa sera illisible. Par ex, je met le mot de passe: 1234, sa donne: "Boqjosp, je r'annel Thoraw, j'ai 12 aqw et roq nwesdo ewt thorvaill."

Voila le travail !
Mais, vous allez voir la longeur de la source, j'ai passé beaucoups de temps dessus !!!

Source / Exemple :


//Voila la source, un peut grande, je sais (779 lignes !!!)(exscusez moi LoL) mais, il y a aussi le ZIP !

<!-- Crée par Thomas VAILLANT: thomas.vaillant-76@laposte.net -->
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<title>Crypteur de texte    par Thomas VAILLANT</title>
</head>

<body>
<?php
@$action=$_GET['action'];

if($action == ""){  //Si il n'y a pas d'action, on écrit la page ci-dessous (pour que l'utilisateur puisse crypter/décrypter son texte)
echo("<h1><strong>Bienvenue sur le crypteur de texte !</strong></h1>");
echo("<p>Entrez votre texte à crypter dans le champ ci-dessous: </p>");
echo("<form name=form-crypt method=post action=index.php?action=crypt>");
echo("  <textarea name=textacrypter cols=50 id=text></textarea>");
echo("  <br>");
echo("ATTENTION: Les lettre en majuscules, les lettres avec des accents et les chiffres ne serons pas cryptés ! <br> ATTENTION: Ne pas utiliser les caractères suivants: * $ £ } ] @ ` | [ { # ~ & € µ % ° + = ^ \ / ² §   car il y aurait des conflits <br>");
echo("Et entrez un mot de passe avec à QUATRE CHIFFRES (ex: 0106 , 9999 ect...)<br>");
echo("Mot de passe: <input name=mdpcrypt1 type=text id=mdpcrypt1 value=0 size=1 maxlength=1><input name=mdpcrypt2 type=text id=mdpcrypt2 value=0 size=1 maxlength=1><input name=mdpcrypt3 type=text id=mdpcrypt3 value=0 size=1 maxlength=1><input name=mdpcrypt4 type=text id=mdpcrypt4 value=0 size=1 maxlength=1> <br>");
echo("  <input name=crypter type=submit id=crypter value=Crypter !>");
echo("</form>");
echo("<hr>");
echo("<p>Entrez votre texte à décrypter dans le champ ci-dessous: </p>");
echo("<form name=form-decrypt method=post action=index.php?action=decrypt>");
echo("  <textarea name=textadecrypter cols=50 id=text></textarea>");
echo("Mot de passe:  <input name=mdpdecrypt1 type=text id=mdpdecrypt1 value=0 size=1 maxlength=1><input name=mdpdecrypt2 type=text id=mdpdecrypt2 value=0 size=1 maxlength=1><input name=mdpdecrypt3 type=text id=mdpdecrypt3 value=0 size=1 maxlength=1><input name=mdpdecrypt4 type=text id=mdpdecrypt4 value=0 size=1 maxlength=1>  <br>");
echo("  <input name=decrypter type=submit id=decrypter value=Décrypter !>");
echo("</form>");

echo("<br><br><br> Crée par <a href=mailto:thomas.vaillant-76@laposte.net> © Thomas VAILLANT © </a>");
}

if($action == "crypt"){  //Si l'action est "crypt", on écrit le programme de cryptage
$textacrypter=$_POST['textacrypter'];  //On récupère le texte non crypté de l'utilisateur
$mdpcrypt1=$_POST['mdpcrypt1'];  //On récupère le premier chiffre du mot de passe à utiliser pour crypter le texte (qui va en fait servire de clé de cryptage)
$mdpcrypt2=$_POST['mdpcrypt2'];  //On récupère le deuxième chiffre du mot de passe à utiliser pour crypter le texte (qui va en fait servire de clé de cryptage)
$mdpcrypt3=$_POST['mdpcrypt3'];  //On récupère le troisième chiffre du mot de passe à utiliser pour crypter le texte (qui va en fait servire de clé de cryptage)
$mdpcrypt4=$_POST['mdpcrypt4'];  //On récupère le quatrième chiffre du mot de passe à utiliser pour crypter le texte (qui va en fait servire de clé de cryptage)

//<---------------------------------------------------------------------------------------------------->
//                            CREATION DE LA CLE DE CRYPTAGE:

//Alphabé de $mdpcrypt1:
if($mdpcrypt1 == 0){
$a="*";
$b="£";
$c="}";
$d="]";
$e="@";
$f="`";
}
if($mdpcrypt1 == 1){
$a="`";
$b="]";
$c="}";
$d="£";
$e="*";
$f="@";
}
if($mdpcrypt1 == 2){
$a="@";
$b="`";
$c="]";
$d="}";
$e="£";
$f="*";
}
if($mdpcrypt1 == 3){
$a="£";
$b="}";
$c="@";
$d="*";
$e="`";
$f="]";
}
if($mdpcrypt1 == 4){
$a="}";
$b="`";
$c="£";
$d="@";
$e="]";
$f="*";
}
if($mdpcrypt1 == 5){
$a="@";
$b="]";
$c="}";
$d="£";
$e="`";
$f="*";
}
if($mdpcrypt1 == 6){
$a="}";
$b="`";
$c="]";
$d="@";
$e="*";
$f="£";
}
if($mdpcrypt1 == 7){
$a="*";
$b="£";
$c="}";
$d="]";
$e="@";
$f="`";
}
if($mdpcrypt1 == 8){
$a="@";
$b="}";
$c="`";
$d="*";
$e="£";
$f="]";
}
if($mdpcrypt1 == 9){
$a="]";
$b="@";
$c="`";
$d="£";
$e="*";
$f="}";
}

//Alphabé de $mdpcrypt2:
if($mdpcrypt2 == 0){
$g="&";
$h="~";
$i="#";
$j="{";
$k="[";
$l="|";
}
if($mdpcrypt2 == 1){
$g="|";
$h="{";
$i="#";
$j="[";
$k="&";
$l="~";
}
if($mdpcrypt2 == 2){
$g="#";
$h="|";
$i="{";
$j="~";
$k="&";
$l="[";
}
if($mdpcrypt2 == 3){
$g="&";
$h="~";
$i="#";
$j="{";
$k="[";
$l="|";
}
if($mdpcrypt2 == 4){
$g="#";
$h="[";
$i="{";
$j="~";
$k="&";
$l="|";
}
if($mdpcrypt2 == 5){
$g="|";
$h="{";
$i="[";
$j="&";
$k="~";
$l="#";
}
if($mdpcrypt2 == 6){
$g="#";
$h="&";
$i="~";
$j="[";
$k="{";
$l="|";
}
if($mdpcrypt2 == 7){
$g="{";
$h="&";
$i="|";
$j="~";
$k="[";
$l="#";
}
if($mdpcrypt2 == 8){
$g="|";
$h="#";
$i="~";
$j="[";
$k="{";
$l="&";
}
if($mdpcrypt2 == 9){
$g="&";
$h="#";
$i="|";
$j="~";
$k="[";
$l="{";
}

//Alphabé de $mdpcrypt3:
if($mdpcrypt3 == 0){
$m="€";
$n="+";
$o="=";
$p="°";
$q="%";
$r="µ";
}
if($mdpcrypt3 == 1){
$m="+";
$n="µ";
$o="%";
$p="=";
$q="€";
$r="°";
}
if($mdpcrypt3 == 2){
$m="%";
$n="+";
$o="°";
$p="=";
$q="µ";
$r="€";
}
if($mdpcrypt3 == 3){
$m="µ";
$n="=";
$o="°";
$p="€";
$q="+";
$r="%";
}
if($mdpcrypt3 == 4){
$m="=";
$n="°";
$o="%";
$p="µ";
$q="+";
$r="€";
}
if($mdpcrypt3 == 5){
$m="+";
$n="%";
$o="µ";
$p="€";
$q="=";
$r="°";
}
if($mdpcrypt3 == 6){
$m="°";
$n="€";
$o="=";
$p="µ";
$q="+";
$r="%";
}
if($mdpcrypt3 == 7){
$m="€";
$n="%";
$o="=";
$p="+";
$q="°";
$r="µ";
}
if($mdpcrypt3 == 8){
$m="µ";
$n="°";
$o="%";
$p="€";
$q="+";
$r="=";
}
if($mdpcrypt3 == 9){
$m="°";
$n="+";
$o="=";
$p="%";
$q="€";
$r="µ";
}

//Alphabé de $mdpcrypt4 (il n'y a pas assé de carractères pour crypter X, Y, Z donc, il ne serons pas cryptés):
if($mdpcrypt4 == 0){
$s="^";
$t="²";
$u="/";
$v="\ ";
$w="§";
}
if($mdpcrypt4 == 1){
$s="²";
$t="§";
$u="/";
$v="\ ";
$w="^";
}
if($mdpcrypt4 == 2){
$s="\ ";
$t="²";
$u="/";
$v="^";
$w="§";
}
if($mdpcrypt4 == 3){
$s="/";
$t="\ ";
$u="§";
$v="^";
$w="²";
}
if($mdpcrypt4 == 4){
$s="^";
$t="/";
$u="²";
$v="\ ";
$w="§";
}
if($mdpcrypt4 == 5){
$s="§";
$t="/";
$u="^";
$v="\ ";
$w="²";
}
if($mdpcrypt4 == 6){
$s="²";
$t="^";
$u="\ ";
$v="§";
$w="/";
}
if($mdpcrypt4 == 7){
$s="\ ";
$t="/";
$u="²";
$v="§";
$w="^";
}
if($mdpcrypt4 == 8){
$s="^";
$t="/";
$u="§";
$v="\ ";
$w="²";
}
if($mdpcrypt4 == 9){
$s="^";
$t="§";
$u="^";
$v="\\";
$w="/ ";
}
//                          FIN DE LA CREATION DE LA CLE DE CRYPTAGE
//<---------------------------------------------------------------------------------------->

//On crypte avec la clé (en utilisant des str_replace() ):
//Ex d'un str_replace:   str_replace("lettre à remplacer","par cette lettre","le texte ou l'on doit remplacer");

$textacrypter = str_replace("a",$a,$textacrypter);
$textacrypter = str_replace("b",$b,$textacrypter);
$textacrypter = str_replace("c",$c,$textacrypter);
$textacrypter = str_replace("d",$d,$textacrypter);
$textacrypter = str_replace("e",$e,$textacrypter);
$textacrypter = str_replace("f",$f,$textacrypter);
$textacrypter = str_replace("g",$g,$textacrypter);
$textacrypter = str_replace("h",$h,$textacrypter);
$textacrypter = str_replace("i",$i,$textacrypter);
$textacrypter = str_replace("j",$j,$textacrypter);
$textacrypter = str_replace("k",$k,$textacrypter);
$textacrypter = str_replace("l",$l,$textacrypter);
$textacrypter = str_replace("m",$m,$textacrypter);
$textacrypter = str_replace("n",$n,$textacrypter);
$textacrypter = str_replace("o",$o,$textacrypter);
$textacrypter = str_replace("p",$p,$textacrypter);
$textacrypter = str_replace("q",$q,$textacrypter);
$textacrypter = str_replace("r",$r,$textacrypter);
$textacrypter = str_replace("s",$s,$textacrypter);
$textacrypter = str_replace("t",$t,$textacrypter);
$textacrypter = str_replace("u",$u,$textacrypter);
$textacrypter = str_replace("v",$v,$textacrypter);
$textacrypter = str_replace("w",$w,$textacrypter);

//On écrit le texte crypté de l'utilisateur:
echo("Voici votre texte crypté: <br>");
echo("<textarea name=textcryptenew cols=50 id=text>$textacrypter</textarea> Pour prendre votre texte crypté, faites un copié/collé !");
echo("<br> ATTENTION: Si vous voulez décrypter votre texte, n'oubliez pas votre mot de passe ! (Votre mot de passe est: $mdpcrypt1$mdpcrypt2$mdpcrypt3$mdpcrypt4 )");
echo("<br> <a href=index.php?action= >Retourner à l'index</a>");

echo("<br><br><br> Crée par <a href=mailto:thomas.vaillant-76@laposte.net> © Thomas VAILLANT © </a>");
}
if($action == "decrypt"){  //Si l'action est: decrypt, on écrit le programme de décryptage:
$textadecrypter=$_POST['textadecrypter'];  //On récupère le texte à décrypter
$mdpdecrypt1=$_POST['mdpdecrypt1'];  //On récupère le premier chiffre du mot de passe à utiliser pour decrypter le texte (qui va en fait servire de clé de decryptage)
$mdpdecrypt2=$_POST['mdpdecrypt2'];  //On récupère le deuxième chiffre du mot de passe à utiliser pour decrypter le texte (qui va en fait servire de clé de decryptage)
$mdpdecrypt3=$_POST['mdpdecrypt3'];  //On récupère le troisième chiffre du mot de passe à utiliser pour decrypter le texte (qui va en fait servire de clé de decryptage)
$mdpdecrypt4=$_POST['mdpdecrypt4'];  //On récupère le quatrième chiffre du mot de passe à utiliser pour decrypter le texte (qui va en fait servire de clé de decryptage)

//<------------------------------------------------------------------------------------------------>
//                        CREATION DE LA CLE DE DECRYPTAGE:

//Alphabé de $mdpdecrypt1:
if($mdpdecrypt1 == 0){
$a="*";
$b="£";
$c="}";
$d="]";
$e="@";
$f="`";
}
if($mdpdecrypt1 == 1){
$a="`";
$b="]";
$c="}";
$d="£";
$e="*";
$f="@";
}
if($mdpdecrypt1 == 2){
$a="@";
$b="`";
$c="]";
$d="}";
$e="£";
$f="*";
}
if($mdpdecrypt1 == 3){
$a="£";
$b="}";
$c="@";
$d="*";
$e="`";
$f="]";
}
if($mdpdecrypt1 == 4){
$a="}";
$b="`";
$c="£";
$d="@";
$e="]";
$f="*";
}
if($mdpdecrypt1 == 5){
$a="@";
$b="]";
$c="}";
$d="£";
$e="`";
$f="*";
}
if($mdpdecrypt1 == 6){
$a="}";
$b="`";
$c="]";
$d="@";
$e="*";
$f="£";
}
if($mdpdecrypt1 == 7){
$a="*";
$b="£";
$c="}";
$d="]";
$e="@";
$f="`";
}
if($mdpdecrypt1 == 8){
$a="@";
$b="}";
$c="`";
$d="*";
$e="£";
$f="]";
}
if($mdpdecrypt1 == 9){
$a="]";
$b="@";
$c="`";
$d="£";
$e="*";
$f="}";
}

//Alphabé de $mdpdecrypt2:
if($mdpdecrypt2 == 0){
$g="&";
$h="~";
$i="#";
$j="{";
$k="[";
$l="|";
}
if($mdpdecrypt2 == 1){
$g="|";
$h="{";
$i="#";
$j="[";
$k="&";
$l="~";
}
if($mdpdecrypt2 == 2){
$g="#";
$h="|";
$i="{";
$j="~";
$k="&";
$l="[";
}
if($mdpdecrypt2 == 3){
$g="&";
$h="~";
$i="#";
$j="{";
$k="[";
$l="|";
}
if($mdpdecrypt2 == 4){
$g="#";
$h="[";
$i="{";
$j="~";
$k="&";
$l="|";
}
if($mdpdecrypt2 == 5){
$g="|";
$h="{";
$i="[";
$j="&";
$k="~";
$l="#";
}
if($mdpdecrypt2 == 6){
$g="#";
$h="&";
$i="~";
$j="[";
$k="{";
$l="|";
}
if($mdpdecrypt2 == 7){
$g="{";
$h="&";
$i="|";
$j="~";
$k="[";
$l="#";
}
if($mdpdecrypt2 == 8){
$g="|";
$h="#";
$i="~";
$j="[";
$k="{";
$l="&";
}
if($mdpdecrypt2 == 9){
$g="&";
$h="#";
$i="|";
$j="~";
$k="[";
$l="{";
}

//Alphabé de $mdpdecrypt3:
if($mdpdecrypt3 == 0){
$m="€";
$n="+";
$o="=";
$p="°";
$q="%";
$r="µ";
}
if($mdpdecrypt3 == 1){
$m="+";
$n="µ";
$o="%";
$p="=";
$q="€";
$r="°";
}
if($mdpdecrypt3 == 2){
$m="%";
$n="+";
$o="°";
$p="=";
$q="µ";
$r="€";
}
if($mdpdecrypt3 == 3){
$m="µ";
$n="=";
$o="°";
$p="€";
$q="+";
$r="%";
}
if($mdpdecrypt3 == 4){
$m="=";
$n="°";
$o="%";
$p="µ";
$q="+";
$r="€";
}
if($mdpdecrypt3 == 5){
$m="+";
$n="%";
$o="µ";
$p="€";
$q="=";
$r="°";
}
if($mdpdecrypt3 == 6){
$m="°";
$n="€";
$o="=";
$p="µ";
$q="+";
$r="%";
}
if($mdpdecrypt3 == 7){
$m="€";
$n="%";
$o="=";
$p="+";
$q="°";
$r="µ";
}
if($mdpdecrypt3 == 8){
$m="µ";
$n="°";
$o="%";
$p="€";
$q="+";
$r="=";
}
if($mdpdecrypt3 == 9){
$m="°";
$n="+";
$o="=";
$p="%";
$q="€";
$r="µ";
}

//Alphabé de $mdpdecrypt4:
if($mdpdecrypt4 == 0){
$s="^";
$t="²";
$u="/";
$v="\ ";
$w="§";
}
if($mdpdecrypt4 == 1){
$s="²";
$t="§";
$u="/";
$v="\ ";
$w="^";
}
if($mdpdecrypt4 == 2){
$s="\ ";
$t="²";
$u="/";
$v="^";
$w="§";
}
if($mdpdecrypt4 == 3){
$s="/";
$t="\ ";
$u="§";
$v="^";
$w="²";
}
if($mdpdecrypt4 == 4){
$s="^";
$t="/";
$u="²";
$v="\ ";
$w="§";
}
if($mdpdecrypt4 == 5){
$s="§";
$t="/";
$u="^";
$v="\ ";
$w="²";
}
if($mdpdecrypt4 == 6){
$s="²";
$t="^";
$u="\ ";
$v="§";
$w="/";
}
if($mdpdecrypt4 == 7){
$s="\ ";
$t="/";
$u="²";
$v="§";
$w="^";
}
if($mdpdecrypt4 == 8){
$s="^";
$t="/";
$u="§";
$v="\ ";
$w="²";
}
if($mdpdecrypt4 == 9){
$s="^";
$t="§";
$u="^";
$v="\\";
$w="/ ";
}
//                       FIN DE LA CLE DE DECRYPTAGE
//<-------------------------------------------------------------------------------------------->

$textadecrypter = str_replace($a,"a",$textadecrypter);
$textadecrypter = str_replace($b,"b",$textadecrypter);
$textadecrypter = str_replace($c,"c",$textadecrypter);
$textadecrypter = str_replace($d,"d",$textadecrypter);
$textadecrypter = str_replace($e,"e",$textadecrypter);
$textadecrypter = str_replace($f,"f",$textadecrypter);
$textadecrypter = str_replace($g,"g",$textadecrypter);
$textadecrypter = str_replace($h,"h",$textadecrypter);
$textadecrypter = str_replace($i,"i",$textadecrypter);
$textadecrypter = str_replace($j,"j",$textadecrypter);
$textadecrypter = str_replace($k,"k",$textadecrypter);
$textadecrypter = str_replace($l,"l",$textadecrypter);
$textadecrypter = str_replace($m,"m",$textadecrypter);
$textadecrypter = str_replace($n,"n",$textadecrypter);
$textadecrypter = str_replace($o,"o",$textadecrypter);
$textadecrypter = str_replace($p,"p",$textadecrypter);
$textadecrypter = str_replace($q,"q",$textadecrypter);
$textadecrypter = str_replace($r,"r",$textadecrypter);
$textadecrypter = str_replace($s,"s",$textadecrypter);
$textadecrypter = str_replace($t,"t",$textadecrypter);
$textadecrypter = str_replace($u,"u",$textadecrypter);
$textadecrypter = str_replace($v,"v",$textadecrypter);
$textadecrypter = str_replace($w,"w",$textadecrypter);

//On écrit le texte décrypté de l'utilisateur:

echo("Voici votre texte décrypté: <br>");
echo("<textarea name=textdecryptenew cols=50 id=text>$textadecrypter</textarea>");
echo("<br> <a href=index.php?action= >Retourner à l'index</a>");

echo("<br><br><br> Crée par <a href=mailto:thomas.vaillant-76@laposte.net> © Thomas VAILLANT © </a>");
}
?>
</body>
</html>
<!-- Crée par Thomas VAILLANT: thomas.vaillant-76@laposte.net -->

Conclusion :


J'atten vos commentaires et vos notes !!!

Codes Sources

A voir également

Vous n'êtes pas encore membre ?

inscrivez-vous, c'est gratuit et ça prend moins d'une minute !

Les membres obtiennent plus de réponses que les utilisateurs anonymes.

Le fait d'être membre vous permet d'avoir un suivi détaillé de vos demandes et codes sources.

Le fait d'être membre vous permet d'avoir des options supplémentaires.