This commit is contained in:
nullptr-0 2023-08-28 22:39:40 +08:00
parent 970d2485a6
commit e3188ef8eb
2 changed files with 6 additions and 7 deletions

View File

@ -2,9 +2,6 @@ import { KgmCrypto } from '@xhacker/kgmwasm/KgmWasmBundle';
import KgmCryptoModule from '@xhacker/kgmwasm/KgmWasmBundle';
import { MergeUint8Array } from '@/utils/MergeUint8Array';
// 每次处理 2M 的数据
const DECRYPTION_BUF_SIZE = 2 *1024 * 1024;
export interface KGMDecryptionResult {
success: boolean;
data: Uint8Array;
@ -34,6 +31,9 @@ export async function DecryptKgmWasm(kgmBlob: ArrayBuffer, ext: string): Promise
return result;
}
// 每次处理 2M 的数据
const DECRYPTION_BUF_SIZE = Math.min(2 *1024 * 1024, kgmBlob.byteLength);
// 申请内存块,并文件末端数据到 WASM 的内存堆
let kgmBuf = new Uint8Array(kgmBlob);
const pQmcBuf = KgmCryptoObj._malloc(DECRYPTION_BUF_SIZE);
@ -41,7 +41,6 @@ export async function DecryptKgmWasm(kgmBlob: ArrayBuffer, ext: string): Promise
// 进行解密初始化
const headerSize = KgmCryptoObj.preDec(pQmcBuf, DECRYPTION_BUF_SIZE, ext);
console.log(headerSize);
kgmBuf = kgmBuf.slice(headerSize);
const decryptedParts = [];

View File

@ -2,9 +2,6 @@ import { QmcCrypto } from '@xhacker/qmcwasm/QmcWasmBundle';
import QmcCryptoModule from '@xhacker/qmcwasm/QmcWasmBundle';
import { MergeUint8Array } from '@/utils/MergeUint8Array';
// 每次处理 2M 的数据
const DECRYPTION_BUF_SIZE = 2 *1024 * 1024;
export interface QMCDecryptionResult {
success: boolean;
data: Uint8Array;
@ -35,6 +32,9 @@ export async function DecryptQmcWasm(qmcBlob: ArrayBuffer, ext: string): Promise
return result;
}
// 每次处理 2M 的数据
const DECRYPTION_BUF_SIZE = Math.min(2 *1024 * 1024, qmcBlob.byteLength);
// 申请内存块,并文件末端数据到 WASM 的内存堆
const qmcBuf = new Uint8Array(qmcBlob);
const pQmcBuf = QmcCryptoObj._malloc(DECRYPTION_BUF_SIZE);