refactor(typescript): Use ES6 import & use interface

This commit is contained in:
Emmm Monster
2021-05-23 23:47:01 +08:00
parent 3c0a9e92f9
commit a1eddb230f
10 changed files with 66 additions and 48 deletions

14
src/decrypt/tm.ts Normal file
View File

@@ -0,0 +1,14 @@
import {Decrypt as RawDecrypt} from "./raw";
import {GetArrayBuffer} from "@/decrypt/utils.ts";
import {DecryptResult} from "@/decrypt/entity";
const TM_HEADER = [0x00, 0x00, 0x00, 0x20, 0x66, 0x74, 0x79, 0x70];
export async function Decrypt(file: File, raw_filename: string): Promise<DecryptResult> {
const audioData = new Uint8Array(await GetArrayBuffer(file));
for (let cur = 0; cur < 8; ++cur) {
audioData[cur] = TM_HEADER[cur];
}
const musicData = new Blob([audioData], {type: "audio/mp4"});
return await RawDecrypt(musicData, raw_filename, "m4a", false)
}