fix: remove static modifier to work with elder babel

This commit is contained in:
鲁树人 2021-12-19 22:49:15 +00:00
parent 6e700df3b9
commit 5f9e3ea590

View File

@ -1,9 +1,9 @@
const { Uint8ArrayEncoder } = require("./utils");
const { getAESSecretKey, decryptAESBlock } = require("./AES");
class DecryptorV4 {
static BLOCK_SIZE = 0x100000 /* data size */ + 0x10 /* padding */;
const BLOCK_SIZE = 0x100000 /* data size */ + 0x10; /* padding */
class DecryptorV4 {
/**
* Derive key from a given seed (user uuid 2)
* @param {string} encryptionSeed
@ -12,15 +12,6 @@ class DecryptorV4 {
this.aesKey = getAESSecretKey(encryptionSeed, null);
}
/**
* Detect if encryption is supported.
* @param {Uint8Array} fileBody File body for detection
*/
static detect(fileBody) {
const magic = Uint8ArrayEncoder.toUTF8(fileBody.slice(0, 4));
return magic === "E!04";
}
/**
* Decrypt a given file.
* @param {Uint8Array} fileBody file body
@ -38,7 +29,7 @@ class DecryptorV4 {
let bytesToDecrypt = fileBody.length;
let i = /* magic */ 4 + /* orig_size */ 8;
while (bytesToDecrypt > 0) {
const blockSize = Math.min(DecryptorV4.BLOCK_SIZE, bytesToDecrypt);
const blockSize = Math.min(BLOCK_SIZE, bytesToDecrypt);
const block = fileBody.subarray(i, i + blockSize);
const blockDecrypted = decryptAESBlock(this.aesKey, block);
blocks.push(blockDecrypted);
@ -50,4 +41,13 @@ class DecryptorV4 {
}
}
/**
* Detect if encryption is supported.
* @param {Uint8Array} fileBody File body for detection
*/
DecryptorV4.detect = (fileBody) => {
const magic = Uint8ArrayEncoder.toUTF8(fileBody.slice(0, 4));
return magic === "E!04";
};
module.exports = DecryptorV4;