From d070332f9862c37b4edb91c9470ca66c2031e60f Mon Sep 17 00:00:00 2001 From: Jixun Wu 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(); + } +}