X1M!
le troller
- Jan 6, 2011
- 179
- 1
This is really easy to use, it will encrypt your variable(s) with base64 and encrypted salts.
There you go, I use that to encrypt session variables.
/ X
PHP:
<?php
/*
SPC ENCRYPTION METHOD
PROVIDED FREE BY X1M!
*/
/* These salt keys are impossible to guess when encrypted. Change these into something impossible to guess. */
define("SALT1", md5("iHasAiPhone"));
define("SALT2", md5(base64_encode("iKnowTheSecret")));
define("SALT3", md5(sha1("iAtePizzaWithFries")));
define("SALT4", md5(base64_encode(sha1("baconAddict63"))));
function SPC_encrypt_string($var) {
/* Also, change the order of the salts. */
return base64_encode(base64_encode(SALT3.SALT1.$var.SALT2.SALT3));
}
function SPC_encrypt_array($array) {
$count = 0;
$returnString = "";
foreach($array as $string) {
$returnString[$count] = SPC_encrypt_string($string);
$count++;
}
return $returnString;
}
function SPC_decrypt_string($var) {
$var = base64_decode(base64_decode($var));
$var = str_ireplace(SALT1, "", $var);
$var = str_ireplace(SALT2, "", $var);
$var = str_ireplace(SALT3, "", $var);
$var = str_ireplace(SALT4, "", $var);
return $var;
}
function SPC_decrypt_array($array) {
$count = 0;
$returnString = "";
foreach($array as $string) {
$returnString[$count] = SPC_decrypt_string($string);
$count++;
}
return $returnString;
}
?>
There you go, I use that to encrypt session variables.
/ X