943,589 Members | Top Members by Rank

Ad:
You are currently viewing page 1 of this multi-page discussion thread
Nov 4th, 2008
0

convert delphi to vb 6.0

Expand Post »
Hello Friends,

Any body help me to convert the code from Delphi to vb 6.0

const
C1 = 43941;
C2 = 16302;

function BorlandEncrypt(const S: String; Key: Word): String;
var
I: byte;
begin
SetLength(Result,Length(S));
for I := 1 to Length(S) do begin
Result[I] := char(byte(S[I]) xor (Key shr 8));
Key := (byte(Result[I]) + Key) * C1 + C2;
end;
end;


function Encrypt(password : string) : string;
begin
{ ----old encrypt ----
result := '';
for i := 1 to length(password) do
result := result + char( (ord(password[i]) xor 43) + 11 ); }

// new encrypt
password := BorlandEncrypt(password,17732);
Result := '<' + Encode64(password) + '>';
//Result := '<' + Encode64(password) + '>';
end;

function Encode64(st : string) : string;
////////////////////////////////////////////////////////////////////////////////
// Base64 Encode a string (RFC 1521)
// Copyright © 2001 - Renier Crause
var
i,idx : integer;
begin
Result := '';
i := 1;
while i <= length(st) do
begin
// 1st char
idx := ord(st[i]) and $FC shr 2;
Result := Result + Alphabet[idx+1];
// 2nd char
idx := (ord(st[i]) and $3 shl 4);
if i+1 <= length(st) then idx := idx + (ord(st[i+1]) and $F0 shr 4);
Result := Result + Alphabet[idx+1];
// 3rd char
if i+1 <= length(st) then
begin
idx := (ord(st[i+1]) and $F shl 2);
if i+2 <= length(st) then idx := idx + (ord(st[i+2]) and $C0 shr 6);
Result := Result + Alphabet[idx+1];
end
else
Result := Result + '=';
// 4th char
if i+2 <= length(st) then
begin
idx := (ord(st[i+2]) and $3F);
Result := Result + Alphabet[idx+1];
end
else
Result := Result + '=';
// next source char
Inc(i,3);
end;
end;


Thanks,
Similar Threads
Reputation Points: 10
Solved Threads: 0
Newbie Poster
poilkjmnb is offline Offline
18 posts
since Nov 2008
Nov 4th, 2008
0

Re: convert delphi to vb 6.0

What have you got so far? We dont tend to do your work for you!
Reputation Points: 196
Solved Threads: 190
Posting Virtuoso
LizR is offline Offline
1,735 posts
since Aug 2008
Nov 4th, 2008
0

Re: convert delphi to vb 6.0

Click to Expand / Collapse  Quote originally posted by LizR ...
What have you got so far? We dont tend to do your work for you!
Hello Lizr,

i m not work in delphi but i need to convert it to vb 6.0 for my application. can u help me to convert this code

function Encode64(st : string) : string;
////////////////////////////////////////////////////////////////////////////////
// Base64 Encode a string (RFC 1521)
// Copyright © 2001 - Renier Crause
var
i,idx : integer;
begin
Result := '';
i := 1;
while i <= length(st) do
begin
// 1st char
idx := ord(st[i]) and $FC shr 2;
Result := Result + Alphabet[idx+1];
// 2nd char
idx := (ord(st[i]) and $3 shl 4);
if i+1 <= length(st) then idx := idx + (ord(st[i+1]) and $F0 shr 4);
Result := Result + Alphabet[idx+1];
// 3rd char
if i+1 <= length(st) then
begin
idx := (ord(st[i+1]) and $F shl 2);
if i+2 <= length(st) then idx := idx + (ord(st[i+2]) and $C0 shr 6);
Result := Result + Alphabet[idx+1];
end
else
Result := Result + '=';
// 4th char
if i+2 <= length(st) then
begin
idx := (ord(st[i+2]) and $3F);
Result := Result + Alphabet[idx+1];
end
else
Result := Result + '=';
// next source char
Inc(i,3);
end;
end;

Thanks,
Reputation Points: 10
Solved Threads: 0
Newbie Poster
poilkjmnb is offline Offline
18 posts
since Nov 2008
Nov 4th, 2008
0

Re: convert delphi to vb 6.0

Dont re-invent the wheel. Download the function done by someone else

http://www.vbforums.com/showthread.php?t=379072
Reputation Points: 196
Solved Threads: 190
Posting Virtuoso
LizR is offline Offline
1,735 posts
since Aug 2008
Nov 4th, 2008
0

Re: convert delphi to vb 6.0

Click to Expand / Collapse  Quote originally posted by LizR ...
Dont re-invent the wheel. Download the function done by someone else

http://www.vbforums.com/showthread.php?t=379072
Thanks LizR.

but this encode string doesn't match the string which is return by delphi code.
Reputation Points: 10
Solved Threads: 0
Newbie Poster
poilkjmnb is offline Offline
18 posts
since Nov 2008
Nov 4th, 2008
0

Re: convert delphi to vb 6.0

hmm, it should as the encode64 function has a standard expectation.

Is the result even remotely similar?
Reputation Points: 196
Solved Threads: 190
Posting Virtuoso
LizR is offline Offline
1,735 posts
since Aug 2008
Nov 4th, 2008
0

Re: convert delphi to vb 6.0

Click to Expand / Collapse  Quote originally posted by LizR ...
hmm, it should as the encode64 function has a standard expectation.

Is the result even remotely similar?
Hello LizR,

when i m enter "pramod" as encode string in delphi code then it return me "NasK3DkF" after encoding.
Reputation Points: 10
Solved Threads: 0
Newbie Poster
poilkjmnb is offline Offline
18 posts
since Nov 2008
Nov 4th, 2008
0

Re: convert delphi to vb 6.0

and in vb 6? (something I dont have installed as I wouldnt use it by choice)
Reputation Points: 196
Solved Threads: 190
Posting Virtuoso
LizR is offline Offline
1,735 posts
since Aug 2008
Jul 23rd, 2010
0
Re: convert delphi to vb 6.0
Form1.Image2.Picture:=Form1.Image1.Picture;
latar:=255;
obyek:=0;
setlength(ki,w,h);
setlength(kio,w,h);
for y:= 0 to hi do
begin
PC :=formutama.image1.picture.bitmap.scanline[y];
PH :=formutama.image2.picture.bitmap.ScanLine[y];
for x:=0 to wj do
begin
ki[x,y]:=PC[x];
kio[x,y]:=PH[x];
end;
end;

for x:= 1 to w-1 do
for y:= 1 to h-1 do
if(ki[x,y]=obyek) then
begin
kio[x-1,y]:=obyek;
kio[x+1,y]:=obyek;
kio[x,y-1]:=obyek;
kio[x,y+1]:=obyek;
end;

for y := 0 to hi do {tampil citra hasil}
begin
PH :=formutama.image2.picture.bitmap.ScanLine[y];
for x:= 0 to wj do PH[x]:=kio[x,y];
end;
ki:=nil;kio:=nil;
Reputation Points: 10
Solved Threads: 0
Newbie Poster
arutya is offline Offline
2 posts
since Jul 2010
Jul 27th, 2010
0

program dilasi delphi to vb

Form1.Image2.Picture:=Form1.Image1.Picture;
latar:=255;
obyek:=0;
setlength(ki,w,h);
setlength(kio,w,h);
for y:= 0 to hi do
begin
PC :=formutama.image1.picture.bitmap.scanline[y];
PH :=formutama.image2.picture.bitmap.ScanLine[y];
for x:=0 to wj do
begin
ki[x,y]:=PC[x];
kio[x,y]:=PH[x];
end;
end;

for x:= 1 to w-1 do
for y:= 1 to h-1 do
if(ki[x,y]=obyek) then
begin
kio[x-1,y]:=obyek;
kio[x+1,y]:=obyek;
kio[x,y-1]:=obyek;
kio[x,y+1]:=obyek;
end;

for y := 0 to hi do {tampil citra hasil}
begin
PH :=formutama.image2.picture.bitmap.ScanLine[y];
for x:= 0 to wj do PH[x]:=kio[x,y];
end;
ki:=nil;kio:=nil;
Reputation Points: 10
Solved Threads: 0
Newbie Poster
arutya is offline Offline
2 posts
since Jul 2010

This thread is solved

Either the thread starter or a moderator has marked this thread as solved. You can most likely trust the responses and answers given. There is most likely no reason for any further responses to be posted here. If you have a related question, please start a new thread in this forum instead.

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in Pascal and Delphi Forum Timeline: Bubble sort not working?
Next Thread in Pascal and Delphi Forum Timeline: Converting Delphi to VB.net or VB 6.0





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC