Convert from Delphi to C#

M

Mel Weaver

Hello,
I'm trying to convert these to functions to c#

const
C1 = 52845;
C2 = 22719;

function Encrypt(const S: String; Key: Word): String;
var
I: byte;
begin
setlength(result,length(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: byte;
begin
setlength(result,length(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;

Thanks
Mel
 
N

Nick Malik [Microsoft]

really lousy encryption.

You may want to consider using the encryption routines in .Net. The one you
show is really bad. Not much better than a secret decoder ring
(http://en.wikipedia.org/wiki/Secret_decoder_ring) on a very slightly better
scale. Still, I wouldn't trust actual sensitive data to it.

--
--- Nick Malik [Microsoft]
MCSD, CFPS, Certified Scrummaster
http://blogs.msdn.com/nickmalik

Disclaimer: Opinions expressed in this forum are my own, and not
representative of my employer.
I do not answer questions on behalf of my employer. I'm just a
programmer helping programmers.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top