From 7cde115ddc3c6c5e3e3a22540100c8ab13357801 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Mon, 11 Dec 2023 18:54:12 +0000 Subject: [PATCH] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- src/renderer/src/progress/index.js | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/renderer/src/progress/index.js b/src/renderer/src/progress/index.js index d2f3229f3..e3b6466d6 100644 --- a/src/renderer/src/progress/index.js +++ b/src/renderer/src/progress/index.js @@ -27,14 +27,15 @@ function encode(text) { const cipher = crypto.createCipheriv(CRYPTO_ALGORITHM, ENCRYPTION_KEY, ENCRYPTION_IV); const encrypted = cipher.update(text); - return `${CRYPTO_VERSION}:${ENCRYPTION_IV.toString("hex")}:${Buffer.concat([encrypted, cipher.final()]).toString("hex")}`; + return `${CRYPTO_VERSION}:${ENCRYPTION_IV.toString("hex")}:${Buffer.concat([encrypted, cipher.final()]).toString( + "hex" + )}`; } // Try to decode the value function decode(text) { + const [TEXT_CRYPTO_VERSION, ENCRYPTION_IV_HEX, encrypted] = text.split(":"); - const [ TEXT_CRYPTO_VERSION, ENCRYPTION_IV_HEX, encrypted ] = text.split(":"); - if (text.slice(0, TEXT_CRYPTO_VERSION.length) !== CRYPTO_VERSION) return undefined; if (!crypto || !/[0-9A-Fa-f]{6}/g.test(encrypted)) return encrypted; @@ -42,7 +43,7 @@ function decode(text) { try { let textParts = encrypted.split(":"); let encryptedText = Buffer.from(textParts.join(":"), "hex"); - let decipher = crypto.createDecipheriv(CRYPTO_ALGORITHM, ENCRYPTION_KEY, Buffer.from(ENCRYPTION_IV_HEX, 'hex')); + let decipher = crypto.createDecipheriv(CRYPTO_ALGORITHM, ENCRYPTION_KEY, Buffer.from(ENCRYPTION_IV_HEX, "hex")); let decrypted = decipher.update(encryptedText); decrypted = Buffer.concat([decrypted, decipher.final()]); return decrypted.toString();