mirror of
https://github.com/asphyxia-core/plugins.git
synced 2026-08-27 05:16:37 -05:00
IIDX: Fixed Base64toBuffer
This commit is contained in:
@@ -43,26 +43,25 @@ export function ClidToPlaySide(clid: number) {
|
|||||||
export function Base64toBuffer(s: string) {
|
export function Base64toBuffer(s: string) {
|
||||||
const base64list =
|
const base64list =
|
||||||
"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";
|
"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";
|
||||||
let t = "",
|
let buffer = Buffer.alloc(0),
|
||||||
p = -8,
|
p = -8,
|
||||||
a = 0,
|
a = 0,
|
||||||
c: number,
|
c: number;
|
||||||
d: number;
|
|
||||||
|
|
||||||
if (s == null) return Buffer.from([0x00]);
|
if (_.isNil(s)) return Buffer.alloc(0);
|
||||||
|
|
||||||
for (let i = 0; i < s.length; i++) {
|
for (let i = 0; i < s.length; i++) {
|
||||||
if ((c = base64list.indexOf(s.charAt(i))) < 0) continue;
|
if ((c = base64list.indexOf(s.charAt(i))) < 0) continue;
|
||||||
|
if (c == 64) break;
|
||||||
a = (a << 6) | (c & 63);
|
a = (a << 6) | (c & 63);
|
||||||
if ((p += 6) >= 0) {
|
if ((p += 6) >= 0) {
|
||||||
d = (a >> p) & 255;
|
buffer = Buffer.concat([buffer, Buffer.from([((a >> p) & 255)])]);
|
||||||
if (c != 64) t += String.fromCharCode(d);
|
|
||||||
a &= 63;
|
a &= 63;
|
||||||
p -= 8;
|
p -= 8;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return Buffer.from(t);
|
return buffer;
|
||||||
}
|
}
|
||||||
|
|
||||||
export function NumArrayToString(bits: number[], numArray: number[]): string {
|
export function NumArrayToString(bits: number[], numArray: number[]): string {
|
||||||
|
|||||||
Reference in New Issue
Block a user