Upgrade to use @unlock-music/crypto #78
@ -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