mirror of
https://github.com/xhacker-zzz/QmcWasm.git
synced 2024-12-05 00:42:17 +00:00
Compare commits
6 Commits
8373c96f38
...
15144510d4
Author | SHA1 | Date | |
---|---|---|---|
15144510d4 | |||
8a876af839 | |||
976b70943a | |||
8875fbdfc7 | |||
333d0ac868 | |||
c7eeeeb57a |
8
.gitignore
vendored
8
.gitignore
vendored
@ -361,3 +361,11 @@ MigrationBackup/
|
||||
|
||||
# Fody - auto-generated XML schema
|
||||
FodyWeavers.xsd
|
||||
|
||||
# content from build
|
||||
npm/LICENSE.txt
|
||||
npm/QmcWasm.wasm
|
||||
npm/QmcLegacy.js
|
||||
npm/QmcWasm.js
|
||||
npm/QmcWasmBundle.js
|
||||
build/
|
@ -26,6 +26,8 @@ const decrypted= (await DecryptQmcWasm(cipherText, extension)).data;
|
||||
|
||||
### 自行构建
|
||||
|
||||
#### 依赖
|
||||
要自行构建此项目,请确保已经安装[Git]与[CMake]且其路径已经添加到 `PATH`
|
||||
#### Linux
|
||||
在此项目根目录中执行 `./build-wasm` 即可构建。构建结果将位于此项目根目录的npm子目录中。
|
||||
#### Windows
|
||||
@ -38,3 +40,5 @@ const decrypted= (await DecryptQmcWasm(cipherText, extension)).data;
|
||||
[授权协议]: https://github.com/nullptr-0/QmcWasm/blob/master/LICENSE.txt
|
||||
[qmc_wasm.ts]: https://github.com/nullptr-0/QmcWasm/blob/master/qmc_wasm.ts
|
||||
[GitHub Actions]: https://github.com/nullptr-0/QmcWasm/actions
|
||||
[Git]: https://git-scm.com/book/en/v2/Getting-Started-Installing-Git
|
||||
[CMake]: https://cmake.org/download/
|
||||
|
@ -11,6 +11,18 @@ if not exist build\emsdk (
|
||||
git clone https://github.com/emscripten-core/emsdk.git build\emsdk
|
||||
)
|
||||
|
||||
rem Check for Ninja binary
|
||||
pushd build\wasm
|
||||
if not exist "ninja.exe" (
|
||||
rem Install Ninja
|
||||
curl -L https://github.com/ninja-build/ninja/releases/download/v1.11.1/ninja-win.zip -o ninja.zip
|
||||
tar -xzvf ninja.zip
|
||||
del ninja.zip
|
||||
)
|
||||
rem must setup PATH for ninja first to avoid conflict with emsdk_env.bat
|
||||
set PATH="%PATH%;%cd%"
|
||||
popd
|
||||
|
||||
pushd build\emsdk
|
||||
rem git pull
|
||||
call emsdk.bat install 3.0.0
|
||||
@ -21,13 +33,6 @@ popd
|
||||
pushd build\wasm
|
||||
|
||||
call emcmake cmake -DCMAKE_BUILD_TYPE=%BUILD_TYPE% ..\..
|
||||
rem Check if Ninja binary exists
|
||||
if not exist "ninja.exe" (
|
||||
rem Install Ninja
|
||||
curl -L https://github.com/ninja-build/ninja/releases/download/v1.11.1/ninja-win.zip -o ninja.zip
|
||||
unzip ninja.zip
|
||||
del ninja.zip
|
||||
)
|
||||
ninja.exe -f build.ninja -j 3
|
||||
|
||||
set "TARGET_FILES=QmcLegacy.js QmcWasm.js QmcWasm.wasm QmcWasmBundle.js %CURR_DIR%\LICENSE.txt"
|
||||
|
@ -8,7 +8,7 @@
|
||||
},
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git+https://github.com/xhacker-zzz/QmcWasm.git"
|
||||
"url": "git+https://github.com/nullptr-0/QmcWasm.git"
|
||||
},
|
||||
"keywords": [
|
||||
"unlock-music",
|
||||
@ -18,7 +18,7 @@
|
||||
"author": "xhacker-zzz",
|
||||
"license": "Apache-2.0",
|
||||
"bugs": {
|
||||
"url": "https://github.com/xhacker-zzz/QmcWasm/issues"
|
||||
"url": "https://github.com/nullptr-0/QmcWasm/issues"
|
||||
},
|
||||
"homepage": "https://github.com/xhacker-zzz/QmcWasm#readme"
|
||||
"homepage": "https://github.com/nullptr-0/QmcWasm#readme"
|
||||
}
|
||||
|
@ -2,7 +2,7 @@ import { QmcCrypto } from '@xhacker/qmcwasm/QmcWasmBundle';
|
||||
import QmcCryptoModule from '@xhacker/qmcwasm/QmcWasmBundle';
|
||||
import { MergeUint8Array } from '@/utils/MergeUint8Array';
|
||||
|
||||
// 每次处理 2M 的数据
|
||||
// 每次可以处理 2M 的数据
|
||||
const DECRYPTION_BUF_SIZE = 2 *1024 * 1024;
|
||||
|
||||
export interface QMCDecryptionResult {
|
||||
@ -38,11 +38,12 @@ export async function DecryptQmcWasm(qmcBlob: ArrayBuffer, ext: string): Promise
|
||||
// 申请内存块,并文件末端数据到 WASM 的内存堆
|
||||
const qmcBuf = new Uint8Array(qmcBlob);
|
||||
const pQmcBuf = QmcCryptoObj._malloc(DECRYPTION_BUF_SIZE);
|
||||
QmcCryptoObj.writeArrayToMemory(qmcBuf.slice(-DECRYPTION_BUF_SIZE), pQmcBuf);
|
||||
const preDecDataSize = Math.min(DECRYPTION_BUF_SIZE, qmcBlob.byteLength); // 初始化缓冲区大小
|
||||
QmcCryptoObj.writeArrayToMemory(qmcBuf.slice(-preDecDataSize), pQmcBuf);
|
||||
|
||||
// 进行解密初始化
|
||||
ext = '.' + ext;
|
||||
const tailSize = QmcCryptoObj.preDec(pQmcBuf, DECRYPTION_BUF_SIZE, ext);
|
||||
const tailSize = QmcCryptoObj.preDec(pQmcBuf, preDecDataSize, ext);
|
||||
if (tailSize == -1) {
|
||||
result.error = QmcCryptoObj.getErr();
|
||||
return result;
|
||||
|
Loading…
Reference in New Issue
Block a user