[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1459
  • Last Modified:

Anybody, can help me calculate the LRC and VRC for strings in Delphi Programming

I want to find the delphi code to solve the LRC and VRC method for strings

Thanks
0
Polors
Asked:
Polors
1 Solution
 
wd123Commented:
i think something like this
function LRC(s:string):char;
var i:integer;
    res:char;
begin
res:=#0;
for I:=1 to length(s) do res:=chr(ord(res) xor ord(s[i]));
result:=res;
end;

Open in new window

0
 
EddieShipmanCommented:
0
 
PolorsAuthor Commented:
I reviewed the link, I think that is the solution to CRC16 and CR32 algorithm, but the functions LRC and VRC works with only that code?
Thanks !!!
0
 
Russell LibbySoftware Engineer, Advisory Commented:
Non assembler versions. (both are trivial routines).

function Vrc(S: String): Byte;
var  i:             Integer;
begin

  // Default result
  result:=0;

  // Walk the string
  for i:=1 to Length(S) do
  begin
     Inc(result, Ord(S[i]));
  end;

end;

function Lrc(S: String): Byte;
var  i:             Integer;
begin

  // Default result
  result:=0;

  // Walk the string
  for i:=1 to Length(S) do
  begin
     result:=result xor Ord(S[i]);
  end;

end;
0
 
PolorsAuthor Commented:
Thanks for all, the solution works.
0

Featured Post

[Webinar] Cloud and Mobile-First Strategy

Maybe you’ve fully adopted the cloud since the beginning. Or maybe you started with on-prem resources but are pursuing a “cloud and mobile first” strategy. Getting to that end state has its challenges. Discover how to build out a 100% cloud and mobile IT strategy in this webinar.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now