Today I read a piece of code to implement the following functions: the server php calls the underlying command, use base64_encode to encrypt the returned results. frontend. js uses the GET method to call the above php to obtain the encrypted text and use the following decryption function to decrypt it. The English is correct, but the Chinese characters are garbled. {Code...} question... today I read a piece of code to implement the following functions:
- The server php calls the underlying command to encrypt the returned results with base64_encode.
- The front-end js uses the GET method to call the above php to obtain the encrypted text and use the following decryption function for decryption. The English language is correct, but the Chinese characters are garbled.
decode_base64_str:function (s) { var e={},i,k,v=[],r='',w=String.fromCharCode; var n=[[65,91],[97,123],[48,58],[43,44],[47,48]]; for(z in n){for(i=n[z][0];i
=8){r+=w((b>>>(l-=8))%256);} } } return r; },
Problem:
- If Chinese characters are not displayed during the encryption and decryption process, is there any risk?
- To decrypt Chinese characters perfectly, which of the above decryption functions is wrong?
Corrected that the strings after encode are directly transmitted through GET between js and php.
PS: I'm not sure whether base64_encode is necessary. The risk I'm talking about is not the leakage of transmitted content, but whether there are risks such as injection, currently, I know that injection occurs when the front end is submitted to the backend. Others are not very familiar.
Reply content:
Today I read a piece of code to implement the following functions:
- The server php calls the underlying command to encrypt the returned results with base64_encode.
- The front-end js uses the GET method to call the above php to obtain the encrypted text and use the following decryption function for decryption. The English language is correct, but the Chinese characters are garbled.
decode_base64_str:function (s) { var e={},i,k,v=[],r='',w=String.fromCharCode; var n=[[65,91],[97,123],[48,58],[43,44],[47,48]]; for(z in n){for(i=n[z][0];i
=8){r+=w((b>>>(l-=8))%256);} } } return r; },
Problem:
- If Chinese characters are not displayed during the encryption and decryption process, is there any risk?
- To decrypt Chinese characters perfectly, which of the above decryption functions is wrong?
Corrected that the strings after encode are directly transmitted through GET between js and php.
PS: I'm not sure whether base64_encode is necessary. The risk I'm talking about is not the leakage of transmitted content, but whether there are risks such as injection, currently, I know that injection occurs when the front end is submitted to the backend. Others are not very familiar.
php
$ Base = base64_encode (urlencode ('Chinese'); // response. log (decodeURIComponent (decode_base64_str ('juu0jui4jufejuu2jtk2jtg3 '); // Chinese