"Go" JS gzip encrypt string and base64 output

Source: Internet
Author: User

Tags: KB name byte stream. com verbose javascrip git receive = =

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

Related Article

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.

Tags Index: