Recently, Base64.js has been used to encrypt URL parameters, and both letters and numbers can be well encrypted/decrypted. However, when testing Chinese, it is not possible to convert, it seems that base64.js does not support medium characters.
Lenovo to encodeURI () encoding/decoding of URLs, but encodeURI, decodeURI can only convert Chinese characters, not support letters and numbers. So want to be able to use encodeURI encoding and then base64 encryption, get the key first with Base64 decryption, and then use decodeURI decoding. It's been tested successfully! Thus, the encryption and decryption of numbers, letters and Chinese characters are realized. The following is the test code:
<script type= "Text/javascript" src= "js/base64.js" ></script><script type= "Text/javascript" >functionBian () {varval = document.getElementById ("BB"). Value; varCom=Base64Encode (encodeURI (Val)); varres = document.getElementById ("Result"); Res.value=com; } functionJie () {varval = document.getElementById ("BB"). Value; varCom=decodeURI (Base64decode (Val)); //document.write (COM); varres = document.getElementById ("Result"); Res.value=com; } </script>
<input type= "text" id= "BB"/><input type= "button" value= "Encode" onclick= "Bian ()" ><input type= "button" Value= "decoding" onclick= "Jie ()" > <br/><input type= "text" id= "result" >
Base64 Chinese cannot encrypt the problem