unpak.js
Version:
Modern TypeScript library for reading Unreal Engine pak files and assets, inspired by CUE4Parse
49 lines • 1.52 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.AbstractAesVfsReader = void 0;
const AbstractVfsReader_1 = require("./AbstractVfsReader");
const Aes_1 = require("../../encryption/aes/Aes");
class AbstractAesVfsReader extends AbstractVfsReader_1.AbstractVfsReader {
constructor(path, versions) {
super(path, versions);
}
length = 0;
customEncryption = null;
aesKey = null;
encryptedFileCount = 0;
/**
* Test all keys from a collection and return the working one if there is one
*/
testAesKeys(keys) {
if (!this.isEncrypted)
return null;
for (const it of keys) {
if (this.testAesKey(it))
return it;
}
return null;
}
/**
* Test all keys from a collection and return the working one if there is one
*/
testAesKeysStr(keys) {
if (!this.isEncrypted)
return null;
for (const it of keys) {
if (this.testAesKeyStr(it))
return it;
}
return null;
}
testAesKey(key) {
return !this.isEncrypted || AbstractAesVfsReader.testAesKey(this.indexCheckBytes(), key);
}
testAesKeyStr(key) {
return this.testAesKey(Aes_1.Aes.parseKey(key));
}
static testAesKey(bytes, key) {
return this.isValidIndex(Aes_1.Aes.decrypt(bytes, key));
}
}
exports.AbstractAesVfsReader = AbstractAesVfsReader;
//# sourceMappingURL=AbstractAesVfsReader.js.map