2020-02-11 06:48:27 +00:00
|
|
|
import {Decrypt as RawDecrypt} from "./raw";
|
2021-05-23 13:59:33 +00:00
|
|
|
import {GetArrayBuffer} from "@/decrypt/utils.ts";
|
2020-01-21 11:21:17 +00:00
|
|
|
|
2020-02-11 06:48:27 +00:00
|
|
|
const TM_HEADER = [0x00, 0x00, 0x00, 0x20, 0x66, 0x74, 0x79, 0x70];
|
|
|
|
|
|
|
|
export async function Decrypt(file, raw_filename) {
|
2021-05-23 13:59:33 +00:00
|
|
|
const audioData = new Uint8Array(await GetArrayBuffer(file));
|
2020-01-21 11:21:17 +00:00
|
|
|
for (let cur = 0; cur < 8; ++cur) {
|
2020-02-11 06:48:27 +00:00
|
|
|
audioData[cur] = TM_HEADER[cur];
|
2020-01-21 11:21:17 +00:00
|
|
|
}
|
|
|
|
const musicData = new Blob([audioData], {type: "audio/mp4"});
|
2020-02-11 07:51:07 +00:00
|
|
|
return await RawDecrypt(musicData, raw_filename, "m4a", false)
|
2020-01-21 11:21:17 +00:00
|
|
|
}
|