Merge remote-tracking branch 'upstream/master'

remotes/origin/HEAD
xhacker-zzz 2 years ago
commit c2556d7cc5

@ -0,0 +1,20 @@
import { DecryptBuffer as DecryptQmcCacheBuffer } from '../qmccache';
import fs from 'fs';
const expectedBuffer = fs.readFileSync(__dirname + '/fixture/qmc_cache_expected.bin');
const createInputBuffer = () => {
const buffer = Buffer.alloc(256);
for (let i = buffer.byteLength; i >= 0; i--) {
buffer[i] = i;
}
return buffer;
};
describe('decrypt/qmccache', () => {
it('should decrypt specified buffer correctly', () => {
const input = createInputBuffer();
DecryptQmcCacheBuffer(input);
expect(input).toEqual(expectedBuffer);
});
});

@ -35,11 +35,9 @@ export async function Decrypt(file: Blob, raw_filename: string, raw_ext: string)
musicDecoded = new Uint8Array(buffer);
let length = musicDecoded.length;
for (let i = 0; i < length; i++) {
musicDecoded[i] ^= 0xf4;
if (musicDecoded[i] <= 0x3f) musicDecoded[i] = musicDecoded[i] * 4;
else if (musicDecoded[i] <= 0x7f) musicDecoded[i] = (musicDecoded[i] - 0x40) * 4 + 1;
else if (musicDecoded[i] <= 0xbf) musicDecoded[i] = (musicDecoded[i] - 0x80) * 4 + 2;
else musicDecoded[i] = (musicDecoded[i] - 0xc0) * 4 + 3;
let byte = musicDecoded[i] ^ 0xf4; // xor 0xf4
byte = ((byte & 0b0011_1111) << 2) | (byte >> 6); // rol 2
musicDecoded[i] = byte;
}
}
let ext = SniffAudioExt(musicDecoded, '');

Loading…
Cancel
Save