Apologies for the novice query, I've inherited some infrastructure and still wrapping my head around the unusual structure they've got setup here.
I have the below in JS and need to replicate the compression in Java but struggling to get the same result or even same structure of output but cant understand why.
I've even tested using echo/unix commands and that seems to match java output structure. (ie piping echo into "| xz -z -9 -c | base64" ) It's almost definitely due to a gap in my understanding of what the javascript is doing here but can someone point me in the right direction/explain why the JS compression is differing so much from java/unix commands
Backing classes:
export default class LZMA {
constructor() {
this.LZMAinternal = new LZMA_WORKER();
}
async compress(input, mode = 9) {
return new Promise((res, rej) => {
// eslint-disable-next-line consistent-return
this.LZMAinternal.compress(input, mode, (result, error) => {
if (result) return res(result);
rej(error);
});
});
}
}
Main function calls (I want to replicate what is returned here in java)
const compressedBuffer = lzmaInstance.LZMAinternal.compress(string);
return Buffer.from(compressedBuffer).toString('base64');
I was attempting to recreate using org.tukaani.xz java library. However output structures look extremely different. Examples below of outputs (base64 encoded after the compression, I've confirmed it's not that base64 encoding that's the issue):
The input stringified json Object:
{"current":1,"resultsPerPage":30,"filters":[],"sortDirection":"desc","sortField":"releasedate","searchTerm":""}
Java/unix output:
/Td6WFoAAATm1rRGAgAhARwAAAAQz1jM4AB5AGZdAD2IiGeUEJx+YNDVSn+g13PJsqImqAnM48D6eQaUMbHDe9+RgNqpzYzom2xwbUPQBqoYmPFSkDFxpTBKCC7IdKwpZ71HTS8zvje4WaeXgtnzpZvdSH5L/KLoKGZAhv/wcTqptSaMKAAAABuSpdXZjxZ9AAGCAXoAAABGCM+pscRn+wIAAAAABFla
JS output:
XQAAgABvAAAAAAAAAAA9iIhnlBCcfmDQ1UrSxfZBo6le37FCAa6Ceb1FGA4qtkbpQAzUfCetkuCC1O3BFgLm8JItARFdH8B8EIEBdZ0dOELKreRlTUht/AvTBOcU0sdtiYF3dEspUYEHFcbYS79m27z//+aLwAA=