数据备份测试

This commit is contained in:
cc
2026-04-25 14:55:31 +08:00
parent c167be53b3
commit 5129574729
21 changed files with 1890 additions and 4 deletions

View File

@@ -10,6 +10,7 @@ type NativeDecryptResult = {
type NativeAddon = {
decryptDatNative: (inputPath: string, xorKey: number, aesKey?: string) => NativeDecryptResult
encryptDatNative?: (inputPath: string, xorKey: number, aesKey?: string) => Buffer
}
let cachedAddon: NativeAddon | null | undefined
@@ -108,3 +109,19 @@ export function decryptDatViaNative(
return null
}
}
export function encryptDatViaNative(
inputPath: string,
xorKey: number,
aesKey?: string
): Buffer | null {
const addon = loadAddon()
if (!addon || typeof addon.encryptDatNative !== 'function') return null
try {
const result = addon.encryptDatNative(inputPath, xorKey, aesKey)
return Buffer.isBuffer(result) ? result : null
} catch {
return null
}
}