http://blog.csdn.net/zunwei/article/details/49886115
Recently encountered some problems in development, about JS how to give a string to the byte stream encryption. The following is a detailed approach,
First introduce pako_deflate.min.js (https://github.com/nodeca/pako/tree/master/dist) plug-in, attachments can be downloaded
Demo
var Applistjson = "{" "Name": "Lvzunwei"} ";
Gzip Encryption: Note Here is the default Gzip method instead of Pako.gzip (applistjson,{to: "string"});
var pakostring = Pako.gzip (Applistjson);
The byte stream after direct gzip cannot be encrypted by a normal Base64 string, because Base64 string encryption intelligently receives a string, so if you use the above pakostring directly base64 will report JS Error!
Base64 byte stream encryption I found a JS on the Geihub but need to change a little bit (HTTPS://GITHUB.COM/BEATGAMMIT/BASE64-JS):
Open the B64.js edit under Lib to remove the red-and-white sections
Uint8tobase64 (pakostring);
This allows you to complete the Base64 encryption of the string gzip encryption and byte stream!
"Go" JS gzip encrypt string and base64 output