Show DevBest [PHP] Secure Encryption Method

Status
Not open for further replies.

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.

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
 

astroids

New Member
Jan 2, 2011
22
0
you coud of easily copy it and add some text, on the other side it did work so thank you
 

X1M!

le troller
Jan 6, 2011
179
1
"you coud of easily copy it and add some text" What do you mean?
 

astroids

New Member
Jan 2, 2011
22
0
wel ass i see

/*
SPC ENCRYPTION METHOD
PROVIDED FREE BY X1M!
*/

Kinda is an add to the text i coud possibly do it
 

X1M!

le troller
Jan 6, 2011
179
1
Dude, use correct fucking grammar. Nobody can understand your bad grammar.



(YES, I AM A GRAMMAR NAZI.)

bump

[MOD]Double posted, Posts merged - Sledmore.[/MOD]​
 

Sway

Ruby and Python are married.
Dec 19, 2010
194
76
wel i whas on my blackberry wen i typed this out so no offence but stil is it easy

All you say it's that it is easy.
You can't do it yourself.

And, I will most probably use this script and edit it for future references.
 

Online

Member
Sep 19, 2010
135
23
you coud of easily copy it and add some text, on the other side it did work so thank you

Your point? He's sharing the code, so of course he's going to copy & paste it. Why waste his time coding it all over again when it's already done for him? he's simply sharing. Sway is right all you do is troll, be more positive.

@astroids if you don't spend much time on php don't comment on it :)
 

astroids

New Member
Jan 2, 2011
22
0
hmm, no online youre just an another account but to be honest this is my first troll if you say so and also it is easy to find on web
 

Online

Member
Sep 19, 2010
135
23
hmm, no online youre just an another account but to be honest this is my first troll if you say so and also it is easy to find on web

Agreed, it is easy to find on the web this is just here for reference. Oh an example, this could be a good reference for you:
 

Sway

Ruby and Python are married.
Dec 19, 2010
194
76
Agreed, it is easy to find on the web this is just here for reference. Oh an example, this could be a good reference for you:

pwned!

And, why did you put the
Code:
/*
SPC ENCRYPTION METHOD
PROVIDED FREE BY X1M!
*/

if it's not yours?
 

Kieren

The OGz
Aug 4, 2010
2,957
751
This thread is not open for spam

Ontopic: It's nice that he has shared the post and has found it on the net to share it with us if you don't like it don't post, this code is useful and in the future someone may use it.
 

X1M!

le troller
Jan 6, 2011
179
1
PHP:
<?php

###########################
#   SPC ENCRYPTION CLASS  #
###########################

class SPC
{
	private SALT1 = "";
	private SALT2 = "";
	private SALT3 = "";
	private SALT4 = "";
	
	function encrypt($string)
	{
		return base64_encode(base64_encode(base64_encode(SALT1.SALT4.$string.SALT3.SALT2)));
	}
	
	function decrypt($string)
	{
		$string = base64_decode(base64_decode(base64_decode(base64_decode($string))));
		$string = str_ireplace(SALT1, "", $string);
		$string = str_ireplace(SALT2, "", $string);
		$string = str_ireplace(SALT3, "", $string);
		$string = str_ireplace(SALT4, "", $string);
		return $string;
	}
}

// Usage: $SPC = new SPC();

?>
OOP friendly version.
 
Status
Not open for further replies.

Users who are viewing this thread

Top