SoFunction
Updated on 2025-04-12

Methods for decrypting gzip encrypted strings in vue

Preface

Today I connect to an interface with the background and receive an encrypted value, saying it was encrypted through gzip, and then I was blinded.

I quickly searched for information on Baidu. Through an article (the original text is at the bottom) I found that there is a JS library that can be decrypted, so I downloaded it and easily decrypted it.

Implement code

Can be downloaded from Github/nodeca/pako or npm install pako

import pako from 'pako'
// One is encryption: (), the other is decryption: ()function decode(encodedData) {
 // Base64 encoding first // Encryption: (), decryption: () let decodedData = (encodedData);
 // To string to array Return a new array where the Unicode table is located let charData = ('').map(x => (0));
 // Uint8Array array type represents an 8-bit unsigned integer array, and the content is initialized to 0 when created.  After creation, you can refer to elements in the array in the form of an object or using array subscript indexing. let binData = new Uint8Array(charData);
 // Call pako to parse let data = (binData);
 // Accept the Unicode value and return the string. decodedData = ( new Uint16Array(data));
 return decodedData
 /**
  * Demo: H4sIAAAAAAAAAAAFWPXQ6AIAyDL2QMavfD/S+m3bIhL1862hVQO8ehAf9gg7g4PmUABM8gDRoyegxX iUljjdhUboRivUipbPEKy0Lk4jbUvYiNrkpIG2ilrXx3vR/pWy5+nrgJlhojzjUjdP5zL5Sz+lo/ AQAA
  *
  */
}
export default decode

Summarize

The above is a detailed explanation of the code used to decrypt gzip encrypted strings in the vue project introduced by the editor. I hope it will be helpful to everyone. If you have any questions, please leave me a message and the editor will reply to everyone in time. Thank you very much for your support for my website!
If you think this article is helpful to you, please reprint it. Please indicate the source, thank you!