mirror of
https://git.unlock-music.dev/um/um-react.git
synced 2024-11-23 20:02:16 +00:00
refactor: simplify kgm decipher
This commit is contained in:
parent
1b116a8db3
commit
73bad51e8e
@ -1,5 +1,5 @@
|
||||
import { DecipherInstance, DecipherOK, DecipherResult, Status } from '~/decrypt-worker/Deciphers';
|
||||
import { KuGouDecipher, KuGouHeader } from '@unlock-music/crypto';
|
||||
import { KuGou } from '@unlock-music/crypto';
|
||||
import type { DecryptCommandOptions } from '~/decrypt-worker/types.ts';
|
||||
import { chunkBuffer } from '~/decrypt-worker/util/buffer.ts';
|
||||
|
||||
@ -7,12 +7,10 @@ export class KugouMusicDecipher implements DecipherInstance {
|
||||
cipherName = 'Kugou';
|
||||
|
||||
async decrypt(buffer: Uint8Array, _options: DecryptCommandOptions): Promise<DecipherResult | DecipherOK> {
|
||||
let kgm: KuGouDecipher | undefined;
|
||||
let header: KuGouHeader | undefined;
|
||||
let kgm: KuGou | undefined;
|
||||
|
||||
try {
|
||||
header = KuGouHeader.parse(buffer.subarray(0, 0x400));
|
||||
kgm = new KuGouDecipher(header);
|
||||
kgm = KuGou.from_header(buffer.subarray(0, 0x400));
|
||||
|
||||
const audioBuffer = new Uint8Array(buffer.subarray(0x400));
|
||||
for (const [block, offset] of chunkBuffer(audioBuffer)) {
|
||||
@ -26,7 +24,6 @@ export class KugouMusicDecipher implements DecipherInstance {
|
||||
};
|
||||
} finally {
|
||||
kgm?.free();
|
||||
header?.free();
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user