forked from um/web
23b096512e
(cherry picked from commit a9aaa40ec48a75967882ef95951bf4f7fccf7a9d)
31 lines
765 B
TypeScript
31 lines
765 B
TypeScript
import {DecryptKey, simpleMakeKey,} from "@/decrypt/qmc_key";
|
|
import fs from "fs";
|
|
|
|
test("key dec: make simple key", () => {
|
|
expect(
|
|
simpleMakeKey(106, 8)
|
|
).toStrictEqual(
|
|
[0x69, 0x56, 0x46, 0x38, 0x2b, 0x20, 0x15, 0x0b]
|
|
)
|
|
})
|
|
|
|
function loadTestDataKeyDecrypt(name: string): {
|
|
cipherText: Uint8Array,
|
|
clearText: Uint8Array
|
|
} {
|
|
return {
|
|
cipherText: fs.readFileSync(`testdata/${name}_key_raw.bin`),
|
|
clearText: fs.readFileSync(`testdata/${name}_key.bin`)
|
|
}
|
|
}
|
|
|
|
test("key dec: real file", async () => {
|
|
const cases = ["mflac_map", "mgg_map", "mflac0_rc4"]
|
|
for (const name of cases) {
|
|
const {clearText, cipherText} = loadTestDataKeyDecrypt(name)
|
|
const buf = DecryptKey(cipherText)
|
|
|
|
expect(buf).toStrictEqual(clearText)
|
|
}
|
|
})
|