1
I’m having a problem converting this function, I wish someone would help me
Code in Delphi
function EnCripta(const InString:string; StartKey,MultKey,AddKey:Integer): string;
var I : Byte;
begin
Result := '';
for I := 1 to Length(InString) do
begin
Result := Result + CHAR(Byte(InString[I]) xor (StartKey shr 8));
StartKey := (Byte(Result[I]) + StartKey) * MultKey + AddKey;
end;
end;
Code in Javascrypt
var EnCripta = function (inString, startKey, multKey, addKey) {
var I;
var result = "";
var vStartKey = startKey;
for (I = 0; I < inString.length; I++) {
var codigo = inString.charCodeAt(I) ^ (startKey >> 8);
codigo = codigo & 0xff;
var a = String.fromCharCode(codigo);
result = result.toString( 'ASCII' ) + a;
startKey = ((result.charCodeAt(I) + startKey) * multKey + addKey);
}
return result;
}
Some words until it works, others don’t
Please if you have anyone help me
Your problem is encoding. Now just know in which of the languages. Passing the string
blablabla
, the Delphi returnsbnm]Ĭإἴ鳜༔
and javascript returnsbnm],%4Ü
– Victor Tadashi
In my case this being in javascript, because I am trying to access a password saved by Delphi
– Paulo
how can I resolve?
– Paulo
Checking a little more I arrived in the database, I’m using the Firebird, with the Node-Firebird
– Paulo