fix: remove static modifier to work with elder babel
This commit is contained in:
parent
6e700df3b9
commit
5f9e3ea590
@ -1,9 +1,9 @@
|
|||||||
const { Uint8ArrayEncoder } = require("./utils");
|
const { Uint8ArrayEncoder } = require("./utils");
|
||||||
const { getAESSecretKey, decryptAESBlock } = require("./AES");
|
const { getAESSecretKey, decryptAESBlock } = require("./AES");
|
||||||
|
|
||||||
class DecryptorV4 {
|
const BLOCK_SIZE = 0x100000 /* data size */ + 0x10; /* padding */
|
||||||
static BLOCK_SIZE = 0x100000 /* data size */ + 0x10 /* padding */;
|
|
||||||
|
|
||||||
|
class DecryptorV4 {
|
||||||
/**
|
/**
|
||||||
* Derive key from a given seed (user uuid 2)
|
* Derive key from a given seed (user uuid 2)
|
||||||
* @param {string} encryptionSeed
|
* @param {string} encryptionSeed
|
||||||
@ -12,15 +12,6 @@ class DecryptorV4 {
|
|||||||
this.aesKey = getAESSecretKey(encryptionSeed, null);
|
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.
|
* Decrypt a given file.
|
||||||
* @param {Uint8Array} fileBody file body
|
* @param {Uint8Array} fileBody file body
|
||||||
@ -38,7 +29,7 @@ class DecryptorV4 {
|
|||||||
let bytesToDecrypt = fileBody.length;
|
let bytesToDecrypt = fileBody.length;
|
||||||
let i = /* magic */ 4 + /* orig_size */ 8;
|
let i = /* magic */ 4 + /* orig_size */ 8;
|
||||||
while (bytesToDecrypt > 0) {
|
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 block = fileBody.subarray(i, i + blockSize);
|
||||||
const blockDecrypted = decryptAESBlock(this.aesKey, block);
|
const blockDecrypted = decryptAESBlock(this.aesKey, block);
|
||||||
blocks.push(blockDecrypted);
|
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;
|
module.exports = DecryptorV4;
|
||||||
|
Loading…
Reference in New Issue
Block a user