feat(QMCv2): add decoder
(cherry picked from commit 29ac94d1fe52e666fda619f8716d2bc0b120a9ee)remotes/origin/HEAD
parent
910b00529e
commit
1ab05bb509
@ -0,0 +1,32 @@
|
|||||||
|
import fs from "fs";
|
||||||
|
import {QmcDecoder} from "@/decrypt/qmc";
|
||||||
|
import {BytesEqual} from "@/decrypt/utils";
|
||||||
|
|
||||||
|
function loadTestDataDecoder(name: string): {
|
||||||
|
cipherText: Uint8Array,
|
||||||
|
clearText: Uint8Array
|
||||||
|
} {
|
||||||
|
const cipherBody = fs.readFileSync(`./testdata/${name}_raw.bin`);
|
||||||
|
const cipherSuffix = fs.readFileSync(`./testdata/${name}_suffix.bin`);
|
||||||
|
const cipherText = new Uint8Array(cipherBody.length + cipherSuffix.length);
|
||||||
|
cipherText.set(cipherBody);
|
||||||
|
cipherText.set(cipherSuffix, cipherBody.length);
|
||||||
|
return {
|
||||||
|
cipherText,
|
||||||
|
clearText: fs.readFileSync(`testdata/${name}_target.bin`)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
test("qmc: real file", async () => {
|
||||||
|
const cases = ["mflac0_rc4", "mflac_map", "mgg_map", "qmc0_static"]
|
||||||
|
for (const name of cases) {
|
||||||
|
const {clearText, cipherText} = loadTestDataDecoder(name)
|
||||||
|
const c = new QmcDecoder(cipherText)
|
||||||
|
const buf = c.decrypt()
|
||||||
|
|
||||||
|
expect(BytesEqual(buf, clearText)).toBeTruthy()
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
|
||||||
|
|
Binary file not shown.
Binary file not shown.
Loading…
Reference in New Issue