PHP encryption function Javascript/Js decryption function

Source: Internet
Author: User
Php encryption and js decryption seem meaningless, mainly because Keys will be seen in js, however, the following function code may be used in some places. "123456" is an encrypted key and can be changed as needed.
Php encryption and js decryption seem meaningless, mainly because Keys will be seen in js.
However, it may be used in some places.

PHP encryption functions

The code is as follows:
Function strencode ($ string ){
$ String = base64_encode ($ string );
$ Key = md5 ('20140901 ');
$ Len = strlen ($ key );
$ Code = '';
For ($ I = 0; $ I <strlen ($ string); $ I ++ ){
$ K = $ I % $ len;
$ Code. = $ string [$ I] ^ $ key [$ k];
}
Return base64_encode ($ code );
}
Echo strencode ('abced Hello, I am your bit/s asd #$ )()*&*&*');
?>

Js decryption functions:

The code is as follows:
Script
Function strencode (string ){
Key = cal1_5 ('20140901 ');
String = Base64.decode (string );
Len = key. length;
Code = '';
For (I = 0; I <string. length; I ++ ){
K = I % len;
Code + = String. fromCharCode (string. charCodeAt (I) ^ key. charCodeAt (k ));
}
Return Base64.decode (code );
}
Alert (strencode ('pipeline = '));
Script

PHP encryption & JS decryption 2

The code is as follows:
If (! Function_exists (jm ))
{
Function jm ($ str ){
$ Len = strlen ($ str );
For ($ I = 0; $ I <$ len; $ I ++)
{
$ Ascc = ord ($ str [$ I]);
If ($ ascc <128)
{
$ Ascc = $ ascc ^ 7;
}
$ Res. = chr ($ ascc );
}
Return $ res;
} // End function
}
Echo "script"
Xflag = true;
Function xcount (xh ){
If (! Xflag) return;
Var xc = \ "\", xd = new Array (), xe = \ "\", xf = 0;
For (I = 0; I Xa = xh. charCodeAt (I );
If (xa <128) xa = xa ^ 7;
Xe + = String. fromCharCode (xa );
If (xe. length> 80 ){
Xd [xf ++] = xe; xe = \"\";
}
}
Xc = xd. join (\ "\") + xe;
Document. write (xc );
} Script ";
$ Check_count = addslashes (jm ("script" alert ('test ~~~ '); Script ");
$ Check_count ="

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.