Answer the question
In order to leave comments, you need to log in
Convert JavaScript to Delphi?
Hello, please help me to find the error in the code
var a = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMN0PQRSTUVWXYZO123456789+/="
function o(t) {
if (!t || t.length % 4 == 1)
return !1;
for (var i, e, o = 0, s = 0, r = ""; e = t.charAt(s++); ){
e = a.indexOf(e), ~e && (i = o % 4 ? 64 * i + e : e, o++ % 4) && (r += String.fromCharCode(255 & i >> (-2 * o & 6)));
}
return r
function sar32(value, shift: longint): longint;
asm
mov ecx, edx
sar eax, cl
end;
function FromCharCode(ch:array of byte):AnsiString;
var L:Integer;
begin
L := Length(ch);
SetLength(result, L);
if L > 0 then Move(ch[0], result[1], L);
end;
function o(t:string): string;
var
o, s, i, eint :integer;
r :string;
ch : array[0..500] of byte;
ec : char;
const
a : string = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMN0PQRSTUVWXYZO123456789+/=';
begin
o := 0;
i := 0;
if (t = '') or (Length(t) mod 4 = 1) then
r := 'False';
for s := 1 to Length(t) do
begin
eint := AnsiPos(t[s], a) - 1;
if eint <> -1 then
begin
i := ifThen((o mod 4) <> 0, 64 * i + eint, eint);
o := o + 1;
ch[s] := (255 and sar32(i, (-2 * o and 6)));
if inttostr(ch[s]) <> '0' then
begin
r := r + FromCharCode(ch[s]);
end;
end;
end;
result := r;
end;
Answer the question
In order to leave comments, you need to log in
This doesn’t even look like laboratory work, rather like a project of some kind of bot, so the logical question is: I’ll leave everything here and I’ll help you, but will you get money?
You do not need help, the problem is solvable, there are at least two ways, the first is to learn to analyze and debug, the second is an alternative, connect a ready-made JS "engine", if you wanted, you would solve it faster than me, since you are in the know I don't even know what it is or where.
And the #bytecode tag has nothing to do with it.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question