|
@ -16,11 +16,9 @@ import { parseBlob as metaParseBlob } from 'music-metadata-browser'; |
|
|
export function DecryptBuffer(buffer: Uint8Array | Buffer) { |
|
|
export function DecryptBuffer(buffer: Uint8Array | Buffer) { |
|
|
let length = buffer.byteLength; |
|
|
let length = buffer.byteLength; |
|
|
for (let i = 0; i < length; i++) { |
|
|
for (let i = 0; i < length; i++) { |
|
|
buffer[i] ^= 0xf4; |
|
|
let byte = buffer[i] ^ 0xf4; // xor 0xf4
|
|
|
if (buffer[i] <= 0x3f) buffer[i] = buffer[i] * 4; |
|
|
byte = ((byte & 0b0011_1111) << 2) | (byte >> 6); // rol 2
|
|
|
else if (buffer[i] <= 0x7f) buffer[i] = (buffer[i] - 0x40) * 4 + 1; |
|
|
buffer[i] = byte; |
|
|
else if (buffer[i] <= 0xbf) buffer[i] = (buffer[i] - 0x80) * 4 + 2; |
|
|
|
|
|
else buffer[i] = (buffer[i] - 0xc0) * 4 + 3; |
|
|
|
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|