mirror of
https://git.um-react.app/um/web.git
synced 2025-12-16 12:13:02 +00:00
refactor(typescript): Use ES6 import & use interface
This commit is contained in:
@@ -9,6 +9,7 @@ import {
|
||||
import {Decrypt as RawDecrypt} from "@/decrypt/raw.ts";
|
||||
|
||||
import {parseBlob as metaParseBlob} from "music-metadata-browser";
|
||||
import {DecryptResult} from "@/decrypt/entity";
|
||||
|
||||
const MagicHeader = [
|
||||
0x79, 0x65, 0x65, 0x6C, 0x69, 0x6F, 0x6E, 0x2D,
|
||||
@@ -16,13 +17,13 @@ const MagicHeader = [
|
||||
]
|
||||
const PreDefinedKey = "MoOtOiTvINGwd2E6n0E1i7L5t2IoOoNk"
|
||||
|
||||
export async function Decrypt(file: File, raw_filename: string, _: string) {
|
||||
export async function Decrypt(file: File, raw_filename: string, _: string): Promise<DecryptResult> {
|
||||
const oriData = new Uint8Array(await GetArrayBuffer(file));
|
||||
if (!BytesHasPrefix(oriData, MagicHeader)) {
|
||||
if (SniffAudioExt(oriData) === "aac") {
|
||||
return await RawDecrypt(file, raw_filename, "aac", true)
|
||||
return await RawDecrypt(file, raw_filename, "aac", false)
|
||||
}
|
||||
return {status: false, message: "Not a valid kwm file!"}
|
||||
throw Error("not a valid kwm file")
|
||||
}
|
||||
|
||||
let fileKey = oriData.slice(0x18, 0x20)
|
||||
|
||||
Reference in New Issue
Block a user