How can I solve the problem of php encoding and corresponding js-side decoding functions?

Source: Internet
Author: User
Request phpflood and its corresponding js decoding code of the js terminal runtime through a.phpgenerated B .html, encryption is not high, but do not base64 self improved, because php and js code is different, resulting in unable to restore the http://topic.csdn.net/u/20121026/21/aa481d57-5268-43 can be php encoding and corresponding js decoding function
The Digest of the JS code is running in B .html generated through a.php. the encryption requirement is not high, but base64 is not required.


I have improved it myself. due to different php and js codes, it cannot be restored.



Http://topic.csdn.net/u/20121026/21/aa481d57-5268-4377-844a-11e0abf9fdd0.html? Seed = 358554303 & r = 80007043 # r_80007043
------ Solution --------------------
I wonder if it meets your needs
Script
Function compile (code ){
Var c = String. fromCharCode (code. charCodeAt (0) + code. length );
For (var I = 1; I C + = String. fromCharCode (code. charCodeAt (I) + code. charCodeAt (i-1 ));
}
Return escape (c );
}
Document. write (compile ('CD in AB '));
Script

Echo compile ('CD in AB ');
Function compile ($ code ){
$ Code = array_values (unpack ('n' * ', iconv (strlen ('hang') = 2? 'Gbk': 'utf-8', 'ucs-2', $ code )));
$ C [] = $ code [0] + count ($ code );
For ($ I = 1; $ I $ C [] = $ code [$ I] + $ code [$ i-1];
}
$ R = '';
Foreach ($ c as $ v ){
If ($ v <256) $ r. = urlencode (chr ($ v ));
Else $ r. = '% u'. strtoupper (dechex ($ v ));
}
Return $ r;
}
Results in GBK environment
F % C3 % u4E8F % u4E90 % C7 f % C3 % u4E8F % u4E90 % C7

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.