<? PHP
/**
** Encoding used for passing string URL parameters
**/
// $ Sxorkey = "ckaua71/| & ^ $ %! @ 9 & # @ & 9237:;: "" [615 kdhak ";
$ Sxorkey = "ckaua71/| & ^ $ %! @ 9 & # @ & 9237:;: "" [[61asdfsfd5kdha324 @#! % Adasfdafasdfk ";
// $ Sprivatekey = "fzja2qjdfasf _ | 'jau7z7cvja "";
$ Sprivatekey = "fzja2qjdfasf _ | 'jau7z7cvjadfasfsafasfsadfasf343353453546fj7r89678a "";
Function binxorencode ($ sinput ){
Global $ sxorkey, $ sprivatekey;
$ Sout = $ sinput ^ str_repeat ($ sxorkey, Ceil (strlen ($ sinput)/strlen ($ sxorkey )));
$ Sout = pack ("H *", MD5 ($ sout. $ sprivatekey). $ sout;
$ Sout = base64_encode ($ sout );
$ Sout = str_replace ("+", $ sout );
$ Sout = str_replace ("/", "_", $ sout );
$ Sout = str_replace ("=", ".", $ sout );
Return $ sout;
}
/**
** Encoding decode used for passing string URL parameters
**/
Function binxordecode ($ sinput ){
Global $ sxorkey, $ sprivatekey;
$ Sinput = str_replace (",", "+", $ sinput );
$ Sinput = str_replace ("_", "/", $ sinput );
$ Sinput = str_replace (".", "=", $ sinput );
$ Sinput = base64_decode ($ sinput );
$ Shash = bin2hex (substr ($ sinput, 0, 16 ));
$ Sinput = substr ($ sinput, 16 );
If ($ Shash! = MD5 ($ sinput. $ sprivatekey) {return false ;}
$ Sout = $ sinput ^ str_repeat ($ sxorkey, Ceil (strlen ($ sinput)/strlen ($ sxorkey )));
Return $ sout;
}
$ String = "I want to encrypt it. I will not accept you if I disagree with anything ";
$ Encode = binxorencode ($ string );
$ Decode = binxordecode ($ encode );
Echo "string: |". $ string. "| ";
Echo "encode: |". $ encode. "| ";
Echo "decode: |". $ Decode. "| ";
?>
Output:
String: | I want to encrypt
What should I do?
Do you disagree?
I will not accept you |
Encode: | ZP, dd3v5x0naf, wh9a59fq25s9_d5pkadvkr55h2hynvkzp284dwg4iajdyxn1h449, and 1t3emkdwqq8. |
Decode: | I want to encrypt
What should I do?
Do you disagree?
I will not accept you |