mirror of
https://git.um-react.app/um/um-react.git
synced 2025-11-28 11:33:02 +00:00
faet: add support of xmly android (#1)
This commit is contained in:
29
src/decrypt-worker/crypto/xmly/xmly_android.ts
Normal file
29
src/decrypt-worker/crypto/xmly/xmly_android.ts
Normal file
@@ -0,0 +1,29 @@
|
||||
import { transformBlob } from '~/decrypt-worker/util/transformBlob';
|
||||
import type { CryptoBase } from '../CryptoBase.js';
|
||||
import { XimalayaAndroidKey, XimalayaX2MKey, XimalayaX3MKey } from './xmly_android.key.js';
|
||||
|
||||
export class XimalayaAndroidCrypto implements CryptoBase {
|
||||
cryptoName = 'Ximalaya/Android';
|
||||
checkByDecryptHeader = true;
|
||||
constructor(private key: XimalayaAndroidKey) {}
|
||||
|
||||
async decrypt(buffer: ArrayBuffer): Promise<Blob> {
|
||||
const { contentKey, init, step } = this.key;
|
||||
return transformBlob(buffer, (p) => {
|
||||
const transformer = p.make.XimalayaAndroid(init, step, contentKey);
|
||||
if (!transformer) {
|
||||
throw new Error('could not make xmly transformer, is key invalid?');
|
||||
}
|
||||
|
||||
return transformer;
|
||||
});
|
||||
}
|
||||
|
||||
public static makeX2M() {
|
||||
return new XimalayaAndroidCrypto(XimalayaX2MKey);
|
||||
}
|
||||
|
||||
public static makeX3M() {
|
||||
return new XimalayaAndroidCrypto(XimalayaX3MKey);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user