From e18e42ae9ad49dd33804b0ee79b21f37768a5028 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=B2=81=E6=A0=91=E4=BA=BA?= Date: Sun, 18 Jun 2023 18:00:31 +0100 Subject: [PATCH] fix: support files that were not encrypted (e.g. `kgma`), close #36 --- src/decrypt-worker/crypto/CryptoFactory.ts | 4 ++++ .../crypto/transparent/transparent.ts | 14 ++++++++++++++ 2 files changed, 18 insertions(+) create mode 100644 src/decrypt-worker/crypto/transparent/transparent.ts diff --git a/src/decrypt-worker/crypto/CryptoFactory.ts b/src/decrypt-worker/crypto/CryptoFactory.ts index 9fa4999..66a9ec4 100644 --- a/src/decrypt-worker/crypto/CryptoFactory.ts +++ b/src/decrypt-worker/crypto/CryptoFactory.ts @@ -8,6 +8,7 @@ import { NCMCrypto } from './ncm/ncm_pc'; import { XimalayaAndroidCrypto } from './xmly/xmly_android'; import { KWMCrypto } from './kwm/kwm'; import { MiguCrypto } from './migu/migu3d_keyless'; +import { TransparentCrypto } from './transparent/transparent'; export const allCryptoFactories: CryptoFactory[] = [ // Xiami (*.xm) @@ -38,4 +39,7 @@ export const allCryptoFactories: CryptoFactory[] = [ // Ximalaya (Android) XimalayaAndroidCrypto.makeX2M, XimalayaAndroidCrypto.makeX3M, + + // Transparent crypto (not encrypted) + TransparentCrypto.make, ]; diff --git a/src/decrypt-worker/crypto/transparent/transparent.ts b/src/decrypt-worker/crypto/transparent/transparent.ts new file mode 100644 index 0000000..78332d3 --- /dev/null +++ b/src/decrypt-worker/crypto/transparent/transparent.ts @@ -0,0 +1,14 @@ +import type { CryptoBase } from '../CryptoBase'; + +export class TransparentCrypto implements CryptoBase { + cryptoName = 'Transparent'; + checkByDecryptHeader = true; + + async decrypt(buffer: ArrayBuffer): Promise { + return new Blob([buffer]); + } + + public static make() { + return new TransparentCrypto(); + } +}