mirror of
https://git.unlock-music.dev/um/um-react.git
synced 2024-11-24 00:02:16 +00:00
refactor: move QMCv2KeyCrypto constructor to shared utility method
This commit is contained in:
parent
2881f70f68
commit
6f1d1423fe
@ -4,6 +4,7 @@ import type { DecryptCommandOptions } from '~/decrypt-worker/types.ts';
|
|||||||
import { SEED, ENC_V2_KEY_1, ENC_V2_KEY_2 } from './qmc_v2.key.ts';
|
import { SEED, ENC_V2_KEY_1, ENC_V2_KEY_2 } from './qmc_v2.key.ts';
|
||||||
import { fetchParakeet } from '@jixun/libparakeet';
|
import { fetchParakeet } from '@jixun/libparakeet';
|
||||||
import { stringToUTF8Bytes } from '~/decrypt-worker/util/utf8Encoder.ts';
|
import { stringToUTF8Bytes } from '~/decrypt-worker/util/utf8Encoder.ts';
|
||||||
|
import { makeQMCv2KeyCrypto } from '~/decrypt-worker/util/qmc2KeyCrypto.ts';
|
||||||
|
|
||||||
export class QMC2Crypto implements CryptoBase {
|
export class QMC2Crypto implements CryptoBase {
|
||||||
cryptoName = 'QMC/v2';
|
cryptoName = 'QMC/v2';
|
||||||
@ -38,7 +39,7 @@ export class QMC2CryptoWithKey implements CryptoBase {
|
|||||||
|
|
||||||
const parakeet = await fetchParakeet();
|
const parakeet = await fetchParakeet();
|
||||||
const key = stringToUTF8Bytes(options.qmc2Key);
|
const key = stringToUTF8Bytes(options.qmc2Key);
|
||||||
const keyCrypto = parakeet.make.QMCv2KeyCrypto(SEED, ENC_V2_KEY_1, ENC_V2_KEY_2);
|
const keyCrypto = makeQMCv2KeyCrypto(parakeet);
|
||||||
return transformBlob(buffer, (p) => p.make.QMCv2EKey(key, keyCrypto), {
|
return transformBlob(buffer, (p) => p.make.QMCv2EKey(key, keyCrypto), {
|
||||||
parakeet,
|
parakeet,
|
||||||
cleanup: () => keyCrypto.delete(),
|
cleanup: () => keyCrypto.delete(),
|
||||||
|
4
src/decrypt-worker/util/qmc2KeyCrypto.ts
Normal file
4
src/decrypt-worker/util/qmc2KeyCrypto.ts
Normal file
@ -0,0 +1,4 @@
|
|||||||
|
import type { Parakeet } from '@jixun/libparakeet';
|
||||||
|
import { SEED, ENC_V2_KEY_1, ENC_V2_KEY_2 } from '../crypto/qmc/qmc_v2.key';
|
||||||
|
|
||||||
|
export const makeQMCv2KeyCrypto = (p: Parakeet) => p.make.QMCv2KeyCrypto(SEED, ENC_V2_KEY_1, ENC_V2_KEY_2);
|
Loading…
Reference in New Issue
Block a user