UNPKG

unreal.js

Version:

A pak reader for games like VALORANT & Fortnite written in Node.JS

49 lines (48 loc) 1.55 kB
"use strict"; 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); this.length = 0; this.customEncryption = null; this.aesKey = null; this.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;