mirror of https://git.fuwafuwa.moe/SMLoadrDev/SMLoadr synced 2024-11-17 05:44:34 +01:00

Better compatibility with Node.js >=10

This commit is contained in:
FatKiwi 2019-03-14 22:27:06 +00:00
parent a247cbb35b
commit 203b9aa287

View File

@ -203,11 +203,6 @@ function initRequest() {
process.exit(1); process.exit(1);
}); });
// Ignore HTTPS certificate
process.env.NODE_TLS_REJECT_UNAUTHORIZED = '0';
// App info // App info
console.log(chalk.cyan('╔══════════════════════════════════════════════════════════════════╗')); console.log(chalk.cyan('╔══════════════════════════════════════════════════════════════════╗'));
console.log(chalk.cyan('║') + chalk.bold.yellow(' SMLoadr v' + packageJson.version + ' ') + chalk.cyan('║')); console.log(chalk.cyan('║') + chalk.bold.yellow(' SMLoadr v' + packageJson.version + ' ') + chalk.cyan('║'));
@ -2108,7 +2103,7 @@ function decryptTrack(trackBuffer, trackInfos) {
let i = 0; let i = 0;
let position = 0; let position = 0;
let decryptedBuffer = new Buffer(trackBuffer.length); let decryptedBuffer = Buffer.alloc(trackBuffer.length);
decryptedBuffer.fill(0); decryptedBuffer.fill(0);
while (position < trackBuffer.length) { while (position < trackBuffer.length) {
@ -2118,14 +2113,14 @@ function decryptTrack(trackBuffer, trackInfos) {
chunkSize = trackBuffer.length - position; chunkSize = trackBuffer.length - position;
} }
let encryptedChunk = new Buffer(chunkSize); let encryptedChunk = Buffer.alloc(chunkSize);
encryptedChunk.fill(0); encryptedChunk.fill(0);
trackBuffer.copy(encryptedChunk, 0, position, position + chunkSize); trackBuffer.copy(encryptedChunk, 0, position, position + chunkSize);
if (i % 3 > 0 || chunkSize < 2048) { if (i % 3 > 0 || chunkSize < 2048) {
// Already decrypted // Already decrypted
} else { } else {
let cipher = crypto.createDecipheriv('bf-cbc', blowFishKey, new Buffer([0, 1, 2, 3, 4, 5, 6, 7])); let cipher = crypto.createDecipheriv('bf-cbc', blowFishKey, Buffer.from([0, 1, 2, 3, 4, 5, 6, 7]));
cipher.setAutoPadding(false); cipher.setAutoPadding(false);
encryptedChunk = cipher.update(encryptedChunk, 'binary', 'binary') + cipher.final(); encryptedChunk = cipher.update(encryptedChunk, 'binary', 'binary') + cipher.final();