2 years ago

#69220

test-img

szemeg

pako.inflate() - Uncaught incorrect header check when trying to decompress data (ReactJS)

Good day. I am creating covid greenpass decoder in React App, and I need help with pako.js. I am trying to inflate Unit8Array which i got from base45 decoding. And I am getting "uncaught incorrect header check" error. I have tried adding {to: "string"} to inflate() method, or using inflateRaw(). I'll be greatful for help. Here's code:

import React from 'react';
import cbor from 'cbor-web';
import base45 from 'base45-js';

const CovidPass = () => {

    const pako = require('pako')

    const decodedBase45 = base45.decode('I2B-KEP2');
    console.log(decodedBase45);
    const decodedPako = pako.inflate(decodedBase45);
    console.log(decodedPako);

    return (
        <>
            <p>{decodedBase45}</p>
        </>
    );
}

export default CovidPass;

decodedBase45 looks like this in console:

Uint8Array(5) [87, 111, 114, 107, 115, buffer: ArrayBuffer(5), byteLength: 5, byteOffset: 0, length: 5, Symbol(Symbol.toStringTag): 'Uint8Array']
0: 87
1: 111
2: 114
3: 107
4: 115
buffer: 
ArrayBuffer(5)
byteLength: 5
byteOffset: 0
length: 5
Symbol(Symbol.toStringTag): "Uint8Array"
[[Prototype]]: Uint8Array

Or maybe you can tell me the way how to do it with zlib?

javascript

reactjs

compression

pako

0 Answers

Your Answer

Accepted video resources