1
111delphi
Unregistered / Unconfirmed
GUEST, unregistred user!
请帮我把下面两个代码转成javascript,谢谢。
const
C1 = 52845;
C2 = 22719;
function Encrypt(const S: string;
Key: Word): string;
var
I: Integer;
begin
Result := S;
for I := 1 to Length(S)do
begin
Result := char(byte(S) xor (Key shr 8));
Key := (byte(Result) + Key) * C1 + C2;
end;
end;
function Decrypt(const S: string;
Key: Word): string;
var
I: Integer;
begin
Result := S;
for I := 1 to Length(S)do
begin
Result := char(byte(S) xor (Key shr 8));
Key := (byte(S) + Key) * C1 + C2;
end;
end;
const
C1 = 52845;
C2 = 22719;
function Encrypt(const S: string;
Key: Word): string;
var
I: Integer;
begin
Result := S;
for I := 1 to Length(S)do
begin
Result := char(byte(S) xor (Key shr 8));
Key := (byte(Result) + Key) * C1 + C2;
end;
end;
function Decrypt(const S: string;
Key: Word): string;
var
I: Integer;
begin
Result := S;
for I := 1 to Length(S)do
begin
Result := char(byte(S) xor (Key shr 8));
Key := (byte(S) + Key) * C1 + C2;
end;
end;