1
0
mirror of https://git.unlock-music.dev/um/web.git synced 2025-03-15 23:44:38 +08:00

15 lines
529 B
JavaScript
Raw Normal View History

2020-02-11 14:48:27 +08:00
import {Decrypt as RawDecrypt} from "./raw";
import {GetArrayBuffer} from "./util";
2020-01-21 19:21:17 +08:00
2020-02-11 14:48:27 +08:00
const TM_HEADER = [0x00, 0x00, 0x00, 0x20, 0x66, 0x74, 0x79, 0x70];
export async function Decrypt(file, raw_filename) {
const fileBuffer = await GetArrayBuffer(file);
2020-01-21 19:21:17 +08:00
const audioData = new Uint8Array(fileBuffer);
for (let cur = 0; cur < 8; ++cur) {
2020-02-11 14:48:27 +08:00
audioData[cur] = TM_HEADER[cur];
2020-01-21 19:21:17 +08:00
}
const musicData = new Blob([audioData], {type: "audio/mp4"});
2020-02-11 15:51:07 +08:00
return await RawDecrypt(musicData, raw_filename, "m4a", false)
2020-01-21 19:21:17 +08:00
}