55 lines
1.2 KiB
PHP
55 lines
1.2 KiB
PHP
<?php
|
|
|
|
// Variables
|
|
// =========
|
|
$cle = "maSuperCle";
|
|
$mdp = "Am7KM1NgUnOOZ1hhjGBMMgBnBzNUYA==";
|
|
|
|
|
|
// Fonctions
|
|
// =========
|
|
|
|
function GenerationCle($Texte,$CleDEncryptage)
|
|
{
|
|
$CleDEncryptage = md5($CleDEncryptage);
|
|
$Compteur=0;
|
|
$VariableTemp = "";
|
|
for ($Ctr=0;$Ctr<strlen($Texte);$Ctr++)
|
|
{
|
|
if ($Compteur==strlen($CleDEncryptage))
|
|
$Compteur=0;
|
|
$VariableTemp.= substr($Texte,$Ctr,1) ^ substr($CleDEncryptage,$Compteur,1);
|
|
$Compteur++;
|
|
}
|
|
return $VariableTemp;
|
|
}
|
|
|
|
function Crypte($Texte,$Cle)
|
|
{
|
|
srand((double)microtime()*1000000);
|
|
$CleDEncryptage = md5(rand(0,32000) );
|
|
$Compteur=0;
|
|
$VariableTemp = "";
|
|
for ($Ctr=0;$Ctr<strlen($Texte);$Ctr++)
|
|
{
|
|
if ($Compteur==strlen($CleDEncryptage))
|
|
$Compteur=0;
|
|
$VariableTemp.= substr($CleDEncryptage,$Compteur,1).(substr($Texte,$Ctr,1) ^ substr($CleDEncryptage,$Compteur,1) );
|
|
$Compteur++;
|
|
}
|
|
return base64_encode(GenerationCle($VariableTemp,$Cle) );
|
|
}
|
|
|
|
function Decrypte($Texte,$Cle)
|
|
{
|
|
$Texte = GenerationCle(base64_decode($Texte),$Cle);
|
|
$VariableTemp = "";
|
|
for ($Ctr=0;$Ctr<strlen($Texte);$Ctr++)
|
|
{
|
|
$md5 = substr($Texte,$Ctr,1);
|
|
$Ctr++;
|
|
$VariableTemp.= (substr($Texte,$Ctr,1) ^ $md5);
|
|
}
|
|
return $VariableTemp;
|
|
}
|
|
?>
|